<?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[Problem mit verbindung zu einem CS:S Server]]></title><description><![CDATA[<p>Moin,</p>
<p>ich wollte über einen UDP-Socket die Info's über meinen CS:S Server empfangen,<br />
was soweit auch ganz gut funktioniert, nur irgendwie bekomm ich nur die halbe Nachricht.</p>
<p>Hier mal mein Code :</p>
<pre><code class="language-cpp">#include &quot;stdafx.h&quot;
#include &lt;iostream&gt;
#include &lt;winsock2.h&gt;
#pragma comment(lib,&quot;ws2_32.lib&quot;)

#define DEFAULT_BUFLEN 1000
#define DEFAULT_PORT &quot;27015&quot;
#define A2S_INFO &quot;\xFF\xFF\xFF\xFF\x54\x53\x6F\x75\x72\x63\x65\x20\x45\x6E\x67\x69\x6E\x65\x20\x51\x75\x65\x72\x79\x00&quot;

int _tmain(int argc, _TCHAR* argv[])
{
    WSADATA wsaData;
    int iResult;

    SOCKET ConnectSocket;
    struct sockaddr_in clientService; 
    char recvbuf[DEFAULT_BUFLEN];
    int recvbuflen = DEFAULT_BUFLEN;

    iResult = WSAStartup(MAKEWORD(2,2), &amp;wsaData);
    if (iResult != NO_ERROR) {
      printf(&quot;WSAStartup failed: %d\n&quot;, iResult);
      return 1;
    }

    ConnectSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
    if (ConnectSocket == INVALID_SOCKET) {
        printf(&quot;Error at socket(): %ld\n&quot;, WSAGetLastError() );
        WSACleanup();
        return 1;
    }

    clientService.sin_family = AF_INET;
    clientService.sin_addr.s_addr = inet_addr( &quot;82.149.234.75&quot; );
    clientService.sin_port = htons( 27015 );

    iResult = connect( ConnectSocket, (SOCKADDR*) &amp;clientService, sizeof(clientService) );
    if ( iResult == SOCKET_ERROR) {
        closesocket (ConnectSocket);
        printf(&quot;Unable to connect to server: %ld\n&quot;, WSAGetLastError());
        WSACleanup();
        return 1;
    }

    iResult = send( ConnectSocket, A2S_INFO, (int)strlen(A2S_INFO), 0 );
    if (iResult == SOCKET_ERROR) {
        printf(&quot;send failed: %d\n&quot;, WSAGetLastError());
        closesocket(ConnectSocket);
        WSACleanup();
        return 1;
    }

    printf(&quot;Bytes Sent: %ld\n&quot;, iResult);

    do {
        iResult = recv(ConnectSocket, recvbuf, recvbuflen, 0);
        if ( iResult &gt; 0 )
            printf(&quot;Bytes received: %d\n&quot;, iResult);
        else if ( iResult == 0 )
            printf(&quot;Connection closed\n&quot;);
        else
            printf(&quot;recv failed: %d\n&quot;, WSAGetLastError());

    } while( iResult = 0 );

	std::cout&lt;&lt;recvbuf;

    iResult = shutdown(ConnectSocket, SD_SEND);
    if (iResult == SOCKET_ERROR) {
        printf(&quot;shutdown failed: %d\n&quot;, WSAGetLastError());
        closesocket(ConnectSocket);
        WSACleanup();
        return 1;
	}

    closesocket(ConnectSocket);
    WSACleanup();

	system(&quot;PAUSE&quot;);
	return 0;
}
</code></pre>
<p>Und hier noch das Developer Wiki von Valve : <a href="http://developer.valvesoftware.com/wiki/Server_Queries" rel="nofollow">http://developer.valvesoftware.com/wiki/Server_Queries</a></p>
<p>Und hier die Nachricht die empfange :</p>
<pre><code>ÿÿÿÿISERVERNAME
</code></pre>
<p>und hier das was ich empfangen _sollte_ :</p>
<pre><code>ÿÿÿÿI.game2xs.com Counter-StrikeSource #1.de_dust.cstrike.Counter-Strike: Source......dl..1.0.0.22.
</code></pre>
<p>Also wie kann ich die ganze Nachricht empfangen?</p>
<p>Ty <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="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/263899/problem-mit-verbindung-zu-einem-cs-s-server</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Sep 2026 21:12:18 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/263899.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 29 Mar 2010 13:20:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit verbindung zu einem CS:S Server on Mon, 29 Mar 2010 13:21:32 GMT]]></title><description><![CDATA[<p>Moin,</p>
<p>ich wollte über einen UDP-Socket die Info's über meinen CS:S Server empfangen,<br />
was soweit auch ganz gut funktioniert, nur irgendwie bekomm ich nur die halbe Nachricht.</p>
<p>Hier mal mein Code :</p>
<pre><code class="language-cpp">#include &quot;stdafx.h&quot;
#include &lt;iostream&gt;
#include &lt;winsock2.h&gt;
#pragma comment(lib,&quot;ws2_32.lib&quot;)

#define DEFAULT_BUFLEN 1000
#define DEFAULT_PORT &quot;27015&quot;
#define A2S_INFO &quot;\xFF\xFF\xFF\xFF\x54\x53\x6F\x75\x72\x63\x65\x20\x45\x6E\x67\x69\x6E\x65\x20\x51\x75\x65\x72\x79\x00&quot;

int _tmain(int argc, _TCHAR* argv[])
{
    WSADATA wsaData;
    int iResult;

    SOCKET ConnectSocket;
    struct sockaddr_in clientService; 
    char recvbuf[DEFAULT_BUFLEN];
    int recvbuflen = DEFAULT_BUFLEN;

    iResult = WSAStartup(MAKEWORD(2,2), &amp;wsaData);
    if (iResult != NO_ERROR) {
      printf(&quot;WSAStartup failed: %d\n&quot;, iResult);
      return 1;
    }

    ConnectSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
    if (ConnectSocket == INVALID_SOCKET) {
        printf(&quot;Error at socket(): %ld\n&quot;, WSAGetLastError() );
        WSACleanup();
        return 1;
    }

    clientService.sin_family = AF_INET;
    clientService.sin_addr.s_addr = inet_addr( &quot;82.149.234.75&quot; );
    clientService.sin_port = htons( 27015 );

    iResult = connect( ConnectSocket, (SOCKADDR*) &amp;clientService, sizeof(clientService) );
    if ( iResult == SOCKET_ERROR) {
        closesocket (ConnectSocket);
        printf(&quot;Unable to connect to server: %ld\n&quot;, WSAGetLastError());
        WSACleanup();
        return 1;
    }

    iResult = send( ConnectSocket, A2S_INFO, (int)strlen(A2S_INFO), 0 );
    if (iResult == SOCKET_ERROR) {
        printf(&quot;send failed: %d\n&quot;, WSAGetLastError());
        closesocket(ConnectSocket);
        WSACleanup();
        return 1;
    }

    printf(&quot;Bytes Sent: %ld\n&quot;, iResult);

    do {
        iResult = recv(ConnectSocket, recvbuf, recvbuflen, 0);
        if ( iResult &gt; 0 )
            printf(&quot;Bytes received: %d\n&quot;, iResult);
        else if ( iResult == 0 )
            printf(&quot;Connection closed\n&quot;);
        else
            printf(&quot;recv failed: %d\n&quot;, WSAGetLastError());

    } while( iResult = 0 );

	std::cout&lt;&lt;recvbuf;

    iResult = shutdown(ConnectSocket, SD_SEND);
    if (iResult == SOCKET_ERROR) {
        printf(&quot;shutdown failed: %d\n&quot;, WSAGetLastError());
        closesocket(ConnectSocket);
        WSACleanup();
        return 1;
	}

    closesocket(ConnectSocket);
    WSACleanup();

	system(&quot;PAUSE&quot;);
	return 0;
}
</code></pre>
<p>Und hier noch das Developer Wiki von Valve : <a href="http://developer.valvesoftware.com/wiki/Server_Queries" rel="nofollow">http://developer.valvesoftware.com/wiki/Server_Queries</a></p>
<p>Und hier die Nachricht die empfange :</p>
<pre><code>ÿÿÿÿISERVERNAME
</code></pre>
<p>und hier das was ich empfangen _sollte_ :</p>
<pre><code>ÿÿÿÿI.game2xs.com Counter-StrikeSource #1.de_dust.cstrike.Counter-Strike: Source......dl..1.0.0.22.
</code></pre>
<p>Also wie kann ich die ganze Nachricht empfangen?</p>
<p>Ty <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="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1875109</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1875109</guid><dc:creator><![CDATA[megagamer]]></dc:creator><pubDate>Mon, 29 Mar 2010 13:21:32 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit verbindung zu einem CS:S Server on Mon, 29 Mar 2010 13:25:35 GMT]]></title><description><![CDATA[<p>Soweit ich mich entsinne enthält die Rückgabe vom Server doch 0-Bytes.. cout hört bei diesen auf auszugeben. Also hast du vermutlich bereits deine gesamte Rückgabe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1875115</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1875115</guid><dc:creator><![CDATA[Janjan]]></dc:creator><pubDate>Mon, 29 Mar 2010 13:25:35 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit verbindung zu einem CS:S Server on Mon, 29 Mar 2010 13:30:35 GMT]]></title><description><![CDATA[<p>Danke für die antwort</p>
<p>wie kann ich denn z.b. dies in einer datei speichern?</p>
<pre><code class="language-cpp">std::ofstream MyFile;
MyFile.open(&quot;C:\\test.txt&quot;)
MyFile &lt;&lt; recvbuf;
MyFile.close();
</code></pre>
<p>Da wird dann ja auch nur bis zum Servernamen gespeichert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1875119</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1875119</guid><dc:creator><![CDATA[megagamer]]></dc:creator><pubDate>Mon, 29 Mar 2010 13:30:35 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit verbindung zu einem CS:S Server on Mon, 29 Mar 2010 13:33:34 GMT]]></title><description><![CDATA[<pre><code>ostream&amp; write ( const char* s , streamsize n );
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1875122</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1875122</guid><dc:creator><![CDATA[Janjan]]></dc:creator><pubDate>Mon, 29 Mar 2010 13:33:34 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit verbindung zu einem CS:S Server on Mon, 29 Mar 2010 13:54:00 GMT]]></title><description><![CDATA[<p>Danke geht jetzt <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/1875131</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1875131</guid><dc:creator><![CDATA[megagamer]]></dc:creator><pubDate>Mon, 29 Mar 2010 13:54:00 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit verbindung zu einem CS:S Server on Thu, 08 Apr 2010 03:30:34 GMT]]></title><description><![CDATA[<p>Hi megagamer,</p>
<p>ich habe gelesen, dass wenn du bei einer UDP-Verbindung die funktion connect() verwendest auch send() und recv() nutzen kannst anstatt sendto() und recvfrom()(was bei dir der fall ist) und da werden die fehlenden Informationen zur Adresse automatisch ergänzt d.h. bei dir gibt es keine weiteren Informationen.</p>
<p>Mit freundlichen Grüßen</p>
<p>Erdem Yüksel</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1879115</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1879115</guid><dc:creator><![CDATA[AslanPencesi]]></dc:creator><pubDate>Thu, 08 Apr 2010 03:30:34 GMT</pubDate></item></channel></rss>