<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Http &amp;amp; Socket Problem...]]></title><description><![CDATA[<p>Hey Leute <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /><br />
bin recht neu in der c++ Welt (ne knappe woche aktiv), naja die grundlagen kann ich aber eigentlich (oop und klassen &amp; syntax etc)<br />
wollte mich ma an die netztwerk programmierung ranmachen und hab mir gedacht ich mach das einefach mal in verbindung mit http <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /><br />
nun habe ich die folgende klasse...</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &quot;Http.h&quot;
#include &lt;windows.h&gt;
#include &lt;winsock2.h&gt;
#include &lt;stdio.h&gt;
#include &lt;sstream&gt;
#include &lt;cstring&gt;
#include &lt;string&gt;
#include &lt;fstream&gt;

using namespace std;

Http::Http()//Constructor
{
    Port = 80;
    SendPacket(FormPacket(&quot;www.google.de&quot;));
}

Http::~Http()//Destructor
{
    //dtor
}

string Http::SendPacket(string Packet)
{
    WSADATA wsa;
    long rc = WSAStartup(MAKEWORD(2,2),&amp;wsa);

    if(rc != 0)
        cout &lt;&lt; &quot;Fehler beim starten von WSA. Fehler: &quot; &lt;&lt; rc &lt;&lt; endl;
    else
        cout &lt;&lt; &quot;WSA erfolgreich gestartet&quot; &lt;&lt; endl;

    SOCKET sock;
    sock = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
    if(sock == INVALID_SOCKET)
        cout &lt;&lt; &quot;Fehler beim erstellen des Sockets. Fehler: &quot; &lt;&lt; WSAGetLastError() &lt;&lt; endl;
    else
        cout &lt;&lt; &quot;Socket erfolgreich erstellt&quot; &lt;&lt; endl;

    SOCKADDR_IN addr;

    memset(&amp;addr,0,sizeof(SOCKADDR_IN)); // zuerst alles auf 0 setzten
    addr.sin_family=AF_INET;
    addr.sin_port=htons(Port); //Port setzen

    rc = HostAufLoesen(const_cast&lt;char *&gt;(Host.c_str()),&amp;addr);

    if(rc == SOCKET_ERROR)
        cout &lt;&lt; &quot;Ip konnte nicht aufgeloest werden&quot; &lt;&lt; endl;
    else
        cout &lt;&lt; &quot;Ip erfolgreich aufgeloest&quot; &lt;&lt; endl;

    rc=connect(sock,(SOCKADDR*)&amp;addr,sizeof(SOCKADDR));

    if(rc==SOCKET_ERROR)
        cout &lt;&lt; &quot;Fehler beim verbinden. Fehler: &quot; &lt;&lt; WSAGetLastError() &lt;&lt; endl;
    else
        cout &lt;&lt; &quot;Verbindung mit &quot; &lt;&lt; Host &lt;&lt; &quot; wurde erfolgreich aufgebaut&quot; &lt;&lt; endl;

    SendAll(sock,Packet.c_str(),Packet.length());

    stringstream out;
    out &lt;&lt; Packet.length();
    cout &lt;&lt; &quot;LAENGE!!:::&quot; &lt;&lt; out.str();

//    if(rc == SOCKET_ERROR)
//        cout &lt;&lt; &quot;Fehler beim senden des Packetes. Fehler: &quot; &lt;&lt; WSAGetLastError() &lt;&lt; endl;
//    else
//        cout &lt;&lt; &quot;Packet erfolgreich gesendet&quot; &lt;&lt; endl;

    char buf2[123456];
    rc = recv(sock, buf2,123456,0);

    if(rc == SOCKET_ERROR)
        cout &lt;&lt; &quot;Fehler beim empfangen der Antwort. Fehler: &quot; &lt;&lt; WSAGetLastError() &lt;&lt; endl;
    else
        cout &lt;&lt; &quot;Antwort erfolgreich empfangen:&quot; &lt;&lt; endl;

    closesocket(sock);
    WSACleanup();

    cout &lt;&lt; buf2 &lt;&lt; endl;

    ofstream myfile;
    myfile.open (&quot;example.html&quot;);
    if(!myfile.is_open())
        cout &lt;&lt; &quot;\nFail!!!!!\n&quot; &lt;&lt; endl;
    myfile &lt;&lt; Packet;
    myfile.close();

    cout &lt;&lt; &quot;PENIS!&quot;;

    return &quot;&quot;;
}

void Http::SendAll(int socket, const char* const buf, const int size)
{
    int bytesSent = 0; // Anzahl Bytes die wir bereits vom Buffer gesendet haben
    do
    {
        bytesSent += send(socket, buf + bytesSent, size - bytesSent, 0);
    } while(bytesSent &lt; size);
}

long Http::HostAufLoesen(char* hostnameOrIp, SOCKADDR_IN* addr)
{
    long rc;
    unsigned long ip;
    HOSTENT* he;
    /* Parameter prüfen */

    if(hostnameOrIp==NULL || addr==NULL)
        return SOCKET_ERROR;
    /* eine IP in hostnameOrIp ? */

    ip=inet_addr(hostnameOrIp);

    /* bei einem fehler liefert inet_addr den Rückgabewert INADDR_NONE */

    if(ip!=INADDR_NONE)
    {
        addr-&gt;sin_addr.s_addr=ip;
        return 0;
    }
    else
    {
        /* Hostname in hostnameOrIp auflösen */
        he=gethostbyname(hostnameOrIp);
        if(he==NULL)
        {
        return SOCKET_ERROR;
        }
    else
    {
        /*die 4 Bytes der IP von he nach addr kopieren */
        memcpy(&amp;(addr-&gt;sin_addr),he-&gt;h_addr_list[0],4);
    }
    return 0;
    }
}

string Http::FormPacket(string sUrl, string sPost, string sType) //Create the Packetstring
{
    if(sPost == &quot;&quot;)
        PacketToSend += &quot;GET &quot; + GetSubPage(sUrl) +&quot; HTTP 1.1\r\n&quot;;
    else
        PacketToSend += &quot;POST &quot; + GetSubPage(sUrl) +&quot; HTTP 1.1\r\n&quot;;

    PacketToSend += &quot;Host: &quot; + GetSubHost(sUrl) + &quot;\r\n&quot;;

    if(UserAgent == &quot;&quot;)
        PacketToSend += &quot;User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)\r\n&quot;;
    else
        PacketToSend += &quot;User-Agent: &quot; + UserAgent + &quot;\r\n&quot;;

    PacketToSend += &quot;Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n&quot;;
    PacketToSend += &quot;Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3\r\n&quot;;
    PacketToSend += &quot;Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n&quot;;
    PacketToSend += &quot;Keep-Alive: 115\r\n&quot;;
    PacketToSend += &quot;Connection: keep-alive\r\n&quot;;

    if(Cookies != &quot;&quot;)
        PacketToSend += &quot;Cookie: &quot; + Cookies + &quot;\r\n&quot;;

    if(Referer != &quot;&quot;)
        PacketToSend += &quot;Referer: &quot; + Referer + &quot;\r\n&quot;;

    if(sPost != &quot;&quot;)
    {
        PacketToSend += &quot;Content-Type: &quot; + sType + &quot;\r\n&quot;;
        PacketToSend += &quot;Content-Length: &quot;;
        stringstream out;
        out &lt;&lt; sPost.length();
        PacketToSend.append(out.str());
        PacketToSend += &quot;\r\n\r\n&quot;;
        PacketToSend += sPost;
    }
    else
    {
        PacketToSend += &quot;\r\n&quot;;
    }

    cout &lt;&lt; &quot;Packet:\r\n\r\n&quot; &lt;&lt; PacketToSend &lt;&lt; endl;

    return PacketToSend;
}

string Http::GetSubPage(string sUrl) // Example: 'http://google.de/index.php' -&gt; '/index.php'
{
    string tUrl;
    string Page;
    if(sUrl[0] == 'h' &amp;&amp; sUrl[1] == 't' &amp;&amp; sUrl[2] == 't' &amp;&amp; sUrl[3] == 'p' &amp;&amp; sUrl[4] == ':' &amp;&amp; sUrl[5] == '/' &amp;&amp; sUrl[6] == '/') // Check if starts with 'http://'
    {
        for(unsigned int c = 7; c &lt; sUrl.size(); c++)
        {
            tUrl += sUrl[c];
        }
    }
    else
    {
        tUrl = sUrl;
    }

    for(unsigned int c = 0; c &lt; tUrl.size(); c++)
    {
        if(tUrl[c] == '/')
        {
            for(unsigned int c2 = c; c2 &lt; tUrl.size(); c2++)
            {
                Page += tUrl[c2];
            }
            break;
        }
    }

    if(Page == &quot;&quot;)
        Page += &quot;/&quot;;

    return Page;
}

string Http::GetSubHost(string sUrl) // Example: 'http://google.de/index.php' -&gt; 'google.de'
{
    string tUrl;
    string bUrl;
    string Host;
    if(sUrl[0] == 'h' &amp;&amp; sUrl[1] == 't' &amp;&amp; sUrl[2] == 't' &amp;&amp; sUrl[3] == 'p' &amp;&amp; sUrl[4] == ':' &amp;&amp; sUrl[5] == '/' &amp;&amp; sUrl[6] == '/') // Check if starts with 'http://'
    {
        for(unsigned int c = 7; c &lt; sUrl.size(); c++)
        {
            tUrl += sUrl[c];
        }
    }
    else
    {
        tUrl = sUrl;
    }

    for(unsigned int c = 0; c &lt; tUrl.size(); c++)
    {
        if(tUrl[c] == '/')
            break;
        Host += tUrl[c];
    }

    Http::Host = Host;

    return Host;
}
</code></pre>
<p>Allerdings bekomme ich bei dieser anfrage immer den http-error-code 400 zurück (invalid request - der server hat die anfrage nicht &quot;verstanden&quot;)</p>
<p>nun... ich hab mir einfach mal wireshark genomm und einmal nen packet von firefox gesniff und einmal das von mir ...</p>
<p>und was raus kommt hier <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>einmal das packet von firefox (also so wie es wahrscheinlich sein sollte):<br />
<a href="http://img827.imageshack.us/img827/9964/rightux.jpg" rel="nofollow">http://img827.imageshack.us/img827/9964/rightux.jpg</a></p>
<p>und einmal mein packet...<br />
<a href="http://img600.imageshack.us/img600/5558/false.jpg" rel="nofollow">http://img600.imageshack.us/img600/5558/false.jpg</a></p>
<p>so leute <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> wär echt super toll wenn mir einer sagen könnte was ich da falsch dran mache ...</p>
<p>thx mfg <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/281952/http-amp-socket-problem</link><generator>RSS for Node</generator><lastBuildDate>Sun, 23 Aug 2026 10:29:57 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/281952.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 10 Feb 2011 20:52:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Http &amp;amp; Socket Problem... on Thu, 10 Feb 2011 20:52:27 GMT]]></title><description><![CDATA[<p>Hey Leute <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /><br />
bin recht neu in der c++ Welt (ne knappe woche aktiv), naja die grundlagen kann ich aber eigentlich (oop und klassen &amp; syntax etc)<br />
wollte mich ma an die netztwerk programmierung ranmachen und hab mir gedacht ich mach das einefach mal in verbindung mit http <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /><br />
nun habe ich die folgende klasse...</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &quot;Http.h&quot;
#include &lt;windows.h&gt;
#include &lt;winsock2.h&gt;
#include &lt;stdio.h&gt;
#include &lt;sstream&gt;
#include &lt;cstring&gt;
#include &lt;string&gt;
#include &lt;fstream&gt;

using namespace std;

Http::Http()//Constructor
{
    Port = 80;
    SendPacket(FormPacket(&quot;www.google.de&quot;));
}

Http::~Http()//Destructor
{
    //dtor
}

string Http::SendPacket(string Packet)
{
    WSADATA wsa;
    long rc = WSAStartup(MAKEWORD(2,2),&amp;wsa);

    if(rc != 0)
        cout &lt;&lt; &quot;Fehler beim starten von WSA. Fehler: &quot; &lt;&lt; rc &lt;&lt; endl;
    else
        cout &lt;&lt; &quot;WSA erfolgreich gestartet&quot; &lt;&lt; endl;

    SOCKET sock;
    sock = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
    if(sock == INVALID_SOCKET)
        cout &lt;&lt; &quot;Fehler beim erstellen des Sockets. Fehler: &quot; &lt;&lt; WSAGetLastError() &lt;&lt; endl;
    else
        cout &lt;&lt; &quot;Socket erfolgreich erstellt&quot; &lt;&lt; endl;

    SOCKADDR_IN addr;

    memset(&amp;addr,0,sizeof(SOCKADDR_IN)); // zuerst alles auf 0 setzten
    addr.sin_family=AF_INET;
    addr.sin_port=htons(Port); //Port setzen

    rc = HostAufLoesen(const_cast&lt;char *&gt;(Host.c_str()),&amp;addr);

    if(rc == SOCKET_ERROR)
        cout &lt;&lt; &quot;Ip konnte nicht aufgeloest werden&quot; &lt;&lt; endl;
    else
        cout &lt;&lt; &quot;Ip erfolgreich aufgeloest&quot; &lt;&lt; endl;

    rc=connect(sock,(SOCKADDR*)&amp;addr,sizeof(SOCKADDR));

    if(rc==SOCKET_ERROR)
        cout &lt;&lt; &quot;Fehler beim verbinden. Fehler: &quot; &lt;&lt; WSAGetLastError() &lt;&lt; endl;
    else
        cout &lt;&lt; &quot;Verbindung mit &quot; &lt;&lt; Host &lt;&lt; &quot; wurde erfolgreich aufgebaut&quot; &lt;&lt; endl;

    SendAll(sock,Packet.c_str(),Packet.length());

    stringstream out;
    out &lt;&lt; Packet.length();
    cout &lt;&lt; &quot;LAENGE!!:::&quot; &lt;&lt; out.str();

//    if(rc == SOCKET_ERROR)
//        cout &lt;&lt; &quot;Fehler beim senden des Packetes. Fehler: &quot; &lt;&lt; WSAGetLastError() &lt;&lt; endl;
//    else
//        cout &lt;&lt; &quot;Packet erfolgreich gesendet&quot; &lt;&lt; endl;

    char buf2[123456];
    rc = recv(sock, buf2,123456,0);

    if(rc == SOCKET_ERROR)
        cout &lt;&lt; &quot;Fehler beim empfangen der Antwort. Fehler: &quot; &lt;&lt; WSAGetLastError() &lt;&lt; endl;
    else
        cout &lt;&lt; &quot;Antwort erfolgreich empfangen:&quot; &lt;&lt; endl;

    closesocket(sock);
    WSACleanup();

    cout &lt;&lt; buf2 &lt;&lt; endl;

    ofstream myfile;
    myfile.open (&quot;example.html&quot;);
    if(!myfile.is_open())
        cout &lt;&lt; &quot;\nFail!!!!!\n&quot; &lt;&lt; endl;
    myfile &lt;&lt; Packet;
    myfile.close();

    cout &lt;&lt; &quot;PENIS!&quot;;

    return &quot;&quot;;
}

void Http::SendAll(int socket, const char* const buf, const int size)
{
    int bytesSent = 0; // Anzahl Bytes die wir bereits vom Buffer gesendet haben
    do
    {
        bytesSent += send(socket, buf + bytesSent, size - bytesSent, 0);
    } while(bytesSent &lt; size);
}

long Http::HostAufLoesen(char* hostnameOrIp, SOCKADDR_IN* addr)
{
    long rc;
    unsigned long ip;
    HOSTENT* he;
    /* Parameter prüfen */

    if(hostnameOrIp==NULL || addr==NULL)
        return SOCKET_ERROR;
    /* eine IP in hostnameOrIp ? */

    ip=inet_addr(hostnameOrIp);

    /* bei einem fehler liefert inet_addr den Rückgabewert INADDR_NONE */

    if(ip!=INADDR_NONE)
    {
        addr-&gt;sin_addr.s_addr=ip;
        return 0;
    }
    else
    {
        /* Hostname in hostnameOrIp auflösen */
        he=gethostbyname(hostnameOrIp);
        if(he==NULL)
        {
        return SOCKET_ERROR;
        }
    else
    {
        /*die 4 Bytes der IP von he nach addr kopieren */
        memcpy(&amp;(addr-&gt;sin_addr),he-&gt;h_addr_list[0],4);
    }
    return 0;
    }
}

string Http::FormPacket(string sUrl, string sPost, string sType) //Create the Packetstring
{
    if(sPost == &quot;&quot;)
        PacketToSend += &quot;GET &quot; + GetSubPage(sUrl) +&quot; HTTP 1.1\r\n&quot;;
    else
        PacketToSend += &quot;POST &quot; + GetSubPage(sUrl) +&quot; HTTP 1.1\r\n&quot;;

    PacketToSend += &quot;Host: &quot; + GetSubHost(sUrl) + &quot;\r\n&quot;;

    if(UserAgent == &quot;&quot;)
        PacketToSend += &quot;User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)\r\n&quot;;
    else
        PacketToSend += &quot;User-Agent: &quot; + UserAgent + &quot;\r\n&quot;;

    PacketToSend += &quot;Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n&quot;;
    PacketToSend += &quot;Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3\r\n&quot;;
    PacketToSend += &quot;Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n&quot;;
    PacketToSend += &quot;Keep-Alive: 115\r\n&quot;;
    PacketToSend += &quot;Connection: keep-alive\r\n&quot;;

    if(Cookies != &quot;&quot;)
        PacketToSend += &quot;Cookie: &quot; + Cookies + &quot;\r\n&quot;;

    if(Referer != &quot;&quot;)
        PacketToSend += &quot;Referer: &quot; + Referer + &quot;\r\n&quot;;

    if(sPost != &quot;&quot;)
    {
        PacketToSend += &quot;Content-Type: &quot; + sType + &quot;\r\n&quot;;
        PacketToSend += &quot;Content-Length: &quot;;
        stringstream out;
        out &lt;&lt; sPost.length();
        PacketToSend.append(out.str());
        PacketToSend += &quot;\r\n\r\n&quot;;
        PacketToSend += sPost;
    }
    else
    {
        PacketToSend += &quot;\r\n&quot;;
    }

    cout &lt;&lt; &quot;Packet:\r\n\r\n&quot; &lt;&lt; PacketToSend &lt;&lt; endl;

    return PacketToSend;
}

string Http::GetSubPage(string sUrl) // Example: 'http://google.de/index.php' -&gt; '/index.php'
{
    string tUrl;
    string Page;
    if(sUrl[0] == 'h' &amp;&amp; sUrl[1] == 't' &amp;&amp; sUrl[2] == 't' &amp;&amp; sUrl[3] == 'p' &amp;&amp; sUrl[4] == ':' &amp;&amp; sUrl[5] == '/' &amp;&amp; sUrl[6] == '/') // Check if starts with 'http://'
    {
        for(unsigned int c = 7; c &lt; sUrl.size(); c++)
        {
            tUrl += sUrl[c];
        }
    }
    else
    {
        tUrl = sUrl;
    }

    for(unsigned int c = 0; c &lt; tUrl.size(); c++)
    {
        if(tUrl[c] == '/')
        {
            for(unsigned int c2 = c; c2 &lt; tUrl.size(); c2++)
            {
                Page += tUrl[c2];
            }
            break;
        }
    }

    if(Page == &quot;&quot;)
        Page += &quot;/&quot;;

    return Page;
}

string Http::GetSubHost(string sUrl) // Example: 'http://google.de/index.php' -&gt; 'google.de'
{
    string tUrl;
    string bUrl;
    string Host;
    if(sUrl[0] == 'h' &amp;&amp; sUrl[1] == 't' &amp;&amp; sUrl[2] == 't' &amp;&amp; sUrl[3] == 'p' &amp;&amp; sUrl[4] == ':' &amp;&amp; sUrl[5] == '/' &amp;&amp; sUrl[6] == '/') // Check if starts with 'http://'
    {
        for(unsigned int c = 7; c &lt; sUrl.size(); c++)
        {
            tUrl += sUrl[c];
        }
    }
    else
    {
        tUrl = sUrl;
    }

    for(unsigned int c = 0; c &lt; tUrl.size(); c++)
    {
        if(tUrl[c] == '/')
            break;
        Host += tUrl[c];
    }

    Http::Host = Host;

    return Host;
}
</code></pre>
<p>Allerdings bekomme ich bei dieser anfrage immer den http-error-code 400 zurück (invalid request - der server hat die anfrage nicht &quot;verstanden&quot;)</p>
<p>nun... ich hab mir einfach mal wireshark genomm und einmal nen packet von firefox gesniff und einmal das von mir ...</p>
<p>und was raus kommt hier <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>einmal das packet von firefox (also so wie es wahrscheinlich sein sollte):<br />
<a href="http://img827.imageshack.us/img827/9964/rightux.jpg" rel="nofollow">http://img827.imageshack.us/img827/9964/rightux.jpg</a></p>
<p>und einmal mein packet...<br />
<a href="http://img600.imageshack.us/img600/5558/false.jpg" rel="nofollow">http://img600.imageshack.us/img600/5558/false.jpg</a></p>
<p>so leute <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> wär echt super toll wenn mir einer sagen könnte was ich da falsch dran mache ...</p>
<p>thx mfg <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2019369</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2019369</guid><dc:creator><![CDATA[Http Noob]]></dc:creator><pubDate>Thu, 10 Feb 2011 20:52:27 GMT</pubDate></item><item><title><![CDATA[Reply to Http &amp;amp; Socket Problem... on Thu, 10 Feb 2011 22:14:38 GMT]]></title><description><![CDATA[<p>Zwar nicht das Problem, aber -&gt; Augenkrebs!</p>
<pre><code class="language-cpp">if(sUrl[0] == 'h' &amp;&amp; sUrl[1] == 't' &amp;&amp; sUrl[2] == 't' &amp;&amp; sUrl[3] == 'p' &amp;&amp; sUrl[4] == ':' &amp;&amp; sUrl[5] == '/' &amp;&amp; sUrl[6] == '/') // Check if starts with 'http://'
</code></pre>
<p>zu</p>
<pre><code class="language-cpp">if(sUrl.find(&quot;http://&quot;) == 0)
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2019393</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2019393</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Thu, 10 Feb 2011 22:14:38 GMT</pubDate></item><item><title><![CDATA[Reply to Http &amp;amp; Socket Problem... on Thu, 10 Feb 2011 22:23:26 GMT]]></title><description><![CDATA[<p>Was ist denn dieser zweite &quot;Hypertext Transfer Protocol&quot; Abschnitt auf dem Bild von deinem Paket, das gehört doch nicht dahin, oder? Die Hex-Daten darin heißen &quot;fertig&quot;. Ist dir da doch irgendwie noch was rein gerutscht? Im Code hier sehe ich nix verkehrtes.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2019396</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2019396</guid><dc:creator><![CDATA[fdfdg]]></dc:creator><pubDate>Thu, 10 Feb 2011 22:23:26 GMT</pubDate></item><item><title><![CDATA[Reply to Http &amp;amp; Socket Problem... on Thu, 10 Feb 2011 22:25:59 GMT]]></title><description><![CDATA[<p>Ist wohl ein &quot;\n&quot; zuviel.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2019397</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2019397</guid><dc:creator><![CDATA[HighLigerBiMBam]]></dc:creator><pubDate>Thu, 10 Feb 2011 22:25:59 GMT</pubDate></item><item><title><![CDATA[Reply to Http &amp;amp; Socket Problem... on Thu, 10 Feb 2011 22:54:50 GMT]]></title><description><![CDATA[<p>Auch nicht das Problem, aber: SendAll macht kein Error-Checking, und das selbe was du bei SendAll machst (in Schleife aufrufen bis alles gesendet wurde) musst du bei recv() auch machen.</p>
<p>Bzw. eigentlich nur bei recv(), denn send() verschickt bei blocking Sockets immer alles, da kann man sich die Schleife auch sparen. Bei recv() wirst du allerdings definitiv ein Problem bekommen, wenn die Antwort mal etwas grösser wird.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2019402</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2019402</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Thu, 10 Feb 2011 22:54:50 GMT</pubDate></item><item><title><![CDATA[Reply to Http &amp;amp; Socket Problem... on Fri, 11 Feb 2011 16:06:48 GMT]]></title><description><![CDATA[<p>@fdfdg das frage ich mich ja auch^^... aber da ist eigentlich nichts zwischengerutscht...</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/24205">@HighLigerBiMBam</a> und wo bitte ;)?</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/13960">@hustbaer</a> mhh jo ok... aber im moment hab ich halt noch nen viel grösseres problem, als das ich nicht die komplette antwort bekomme^^</p>
<p>thx mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2019755</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2019755</guid><dc:creator><![CDATA[Http Noob]]></dc:creator><pubDate>Fri, 11 Feb 2011 16:06:48 GMT</pubDate></item><item><title><![CDATA[Reply to Http &amp;amp; Socket Problem... on Fri, 11 Feb 2011 18:05:00 GMT]]></title><description><![CDATA[<p>GET HTTP 1.1 -&gt; Pfad <strong>/</strong> fehlt und hier auch HTTP**/**1.1.<br />
GET / HTTP/1.1 muss es heissen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2019805</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2019805</guid><dc:creator><![CDATA[EOP]]></dc:creator><pubDate>Fri, 11 Feb 2011 18:05:00 GMT</pubDate></item><item><title><![CDATA[Reply to Http &amp;amp; Socket Problem... on Fri, 11 Feb 2011 18:49:49 GMT]]></title><description><![CDATA[<p>hey danke deine antwort war echt hilfreich...<br />
also es lag an folgendem...</p>
<p>Meine version:</p>
<pre><code class="language-cpp">GET / HTTP 1.1
</code></pre>
<p>Und so muss es sein:</p>
<pre><code class="language-cpp">GET / HTTP/1.1
</code></pre>
<p>danke bis hier hin <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> und wenn mir jetzt noch einer sagen könnte wie ich mit großen tcp antworten umgehe bin ich wirklich sehr dankbar <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2019828</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2019828</guid><dc:creator><![CDATA[Http Noob]]></dc:creator><pubDate>Fri, 11 Feb 2011 18:49:49 GMT</pubDate></item><item><title><![CDATA[Reply to Http &amp;amp; Socket Problem... on Fri, 11 Feb 2011 18:58:31 GMT]]></title><description><![CDATA[<p>Http Noob schrieb:</p>
<blockquote>
<p>Hey Leute <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /><br />
...naja die grundlagen kann ich aber eigentlich (oop und klassen &amp; syntax etc)...</p>
</blockquote>
<p>Natürlich <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>Sieht man auch gut an deinem code.<br />
Kleines Beispiel:</p>
<p>Http Noob schrieb:</p>
<blockquote>
<pre><code class="language-cpp">string Http::GetSubHost(string sUrl) // Example: 'http://google.de/index.php' -&gt; 'google.de'
{
    string tUrl;
    string bUrl;
    string Host;
    if(sUrl[0] == 'h' &amp;&amp; sUrl[1] == 't' &amp;&amp; sUrl[2] == 't' &amp;&amp; sUrl[3] == 'p' &amp;&amp; sUrl[4] == ':' &amp;&amp; sUrl[5] == '/' &amp;&amp; sUrl[6] == '/') // Check if starts with 'http://'
    {
        for(unsigned int c = 7; c &lt; sUrl.size(); c++)
        {
            tUrl += sUrl[c];
        }
    }
    else
    {
        tUrl = sUrl;
    }

    for(unsigned int c = 0; c &lt; tUrl.size(); c++)
    {
        if(tUrl[c] == '/')
            break;
        Host += tUrl[c];
    }

    Http::Host = Host;

    return Host;
}
</code></pre>
</blockquote>
<p>Alternative:</p>
<pre><code class="language-cpp">std::string trim(const std::string&amp; url) {
	std::string host(url);
	if (host.find(&quot;http://&quot;)==0)
		host.erase(0,7);
	return host.substr(0,host.find(&quot;/&quot;));
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2019831</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2019831</guid><dc:creator><![CDATA[erstmal grundlagen lernen]]></dc:creator><pubDate>Fri, 11 Feb 2011 18:58:31 GMT</pubDate></item><item><title><![CDATA[Reply to Http &amp;amp; Socket Problem... on Fri, 11 Feb 2011 19:07:50 GMT]]></title><description><![CDATA[<p>Sehr schön du schlaumeier^^</p>
<p>Da ich keine lust hatte mich in die methoden der strings einzulesen hab ichs einfach selfmade erstma gemacht ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2019833</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2019833</guid><dc:creator><![CDATA[Http Noob]]></dc:creator><pubDate>Fri, 11 Feb 2011 19:07:50 GMT</pubDate></item><item><title><![CDATA[Reply to Http &amp;amp; Socket Problem... on Fri, 11 Feb 2011 19:11:58 GMT]]></title><description><![CDATA[<p>Http Noob schrieb:</p>
<blockquote>
<p>und wenn mir jetzt noch einer sagen könnte wie ich mit großen tcp antworten umgehe bin ich wirklich sehr dankbar <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
</blockquote>
<p>Du musst recv in einer Schleife aufrufen und zwischen 1. Transfer-Encoding: chunked, 2. Content-Length und 3. Simple (gulp) unterscheiden.</p>
<p>Das wirst du nicht in einem Tag hinkriegen.</p>
<p>also etwa so:<br />
recv bis der header komplett ist, dann den header analysieren und dann wie oben angedeutet fortfahren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2019834</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2019834</guid><dc:creator><![CDATA[EOP]]></dc:creator><pubDate>Fri, 11 Feb 2011 19:11:58 GMT</pubDate></item><item><title><![CDATA[Reply to Http &amp;amp; Socket Problem... on Fri, 11 Feb 2011 19:51:52 GMT]]></title><description><![CDATA[<p>Das ist doch in dem Artikel gut erklärt:</p>
<p><a href="http://www.c-plusplus.net/forum/169861" rel="nofollow">http://www.c-plusplus.net/forum/169861</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2019857</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2019857</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Fri, 11 Feb 2011 19:51:52 GMT</pubDate></item><item><title><![CDATA[Reply to Http &amp;amp; Socket Problem... on Fri, 11 Feb 2011 23:12:03 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/16940">@EOP</a>: Connection=Close und Content-Length sind relativ einfach hinzubekommen. Und Transfer-Encoding: chunked muss man ja nicht akzeptieren - gibt ja auch noch HTTP 1.0.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2019909</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2019909</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Fri, 11 Feb 2011 23:12:03 GMT</pubDate></item><item><title><![CDATA[Reply to Http &amp;amp; Socket Problem... on Fri, 11 Feb 2011 23:43:01 GMT]]></title><description><![CDATA[<p>naja ihr habt mir mit euren tipps schonmal sehr gehilfen bisher <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title="=)"
      alt="🙂"
    /><br />
Ich werde da morgen einfach nen bischen rumprobiern werde das schon irgendwie hinbekommen^^</p>
<p>thx</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2019919</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2019919</guid><dc:creator><![CDATA[Http Noob]]></dc:creator><pubDate>Fri, 11 Feb 2011 23:43:01 GMT</pubDate></item></channel></rss>