<?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[sockets: Serverantwort komplett auslesen]]></title><description><![CDATA[<p>Hallo:<br />
woher weiss der Client, dass er die Antwort vom Server vollständig erhalten hat?</p>
<p>bissl Pseudo-Code:</p>
<pre><code>// zum Server verbinden
connect();

// Antwort auslesen
response = recv();

// mit der Serverantwort irgendwas anstellen.
// Antwort muss aber komplett ausgelesen sein
doSomething(response);
</code></pre>
<p>Konkret geht's darum, die Statusmeldungen bei einer FTP-Verbindung auszulesen.<br />
(Stress macht hauptsächlich der Serverwelcome nach dem connect(), wenn dieser zu lange ist)</p>
<p>Geholfen hat ein Sleep() zwischen connect() und recv().<br />
Aber wie lange soll das Programm schlafen?<br />
1000 ms?<br />
Wenn der Server aber mal einen schlechten Tag hat, und 1500ms braucht?</p>
<p>Danke schon im Voraus.<br />
Martin</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/124068/sockets-serverantwort-komplett-auslesen</link><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Jul 2026 04:25:35 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/124068.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 23 Oct 2005 11:33:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to sockets: Serverantwort komplett auslesen on Sun, 23 Oct 2005 11:33:43 GMT]]></title><description><![CDATA[<p>Hallo:<br />
woher weiss der Client, dass er die Antwort vom Server vollständig erhalten hat?</p>
<p>bissl Pseudo-Code:</p>
<pre><code>// zum Server verbinden
connect();

// Antwort auslesen
response = recv();

// mit der Serverantwort irgendwas anstellen.
// Antwort muss aber komplett ausgelesen sein
doSomething(response);
</code></pre>
<p>Konkret geht's darum, die Statusmeldungen bei einer FTP-Verbindung auszulesen.<br />
(Stress macht hauptsächlich der Serverwelcome nach dem connect(), wenn dieser zu lange ist)</p>
<p>Geholfen hat ein Sleep() zwischen connect() und recv().<br />
Aber wie lange soll das Programm schlafen?<br />
1000 ms?<br />
Wenn der Server aber mal einen schlechten Tag hat, und 1500ms braucht?</p>
<p>Danke schon im Voraus.<br />
Martin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/899226</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/899226</guid><dc:creator><![CDATA[anonymus]]></dc:creator><pubDate>Sun, 23 Oct 2005 11:33:43 GMT</pubDate></item><item><title><![CDATA[Reply to sockets: Serverantwort komplett auslesen on Sun, 23 Oct 2005 13:46:15 GMT]]></title><description><![CDATA[<p>hi all,</p>
<p>schau mal das hier an:</p>
<pre><code class="language-cpp">int bytest_recv;

while( (bytes_recv = recv(sock, buf, sizeof(buf), 0)) &gt; 0 )
{
   write ( 1, buf, bytes_recv);
}

if( bytes_recv == -1 )
   printf(&quot;Error\n&quot;);
</code></pre>
<p>also zeichenweise empfangen bis alles empfangen ist, also solange bytes_recv&gt;0 <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/899314</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/899314</guid><dc:creator><![CDATA[Ausländer]]></dc:creator><pubDate>Sun, 23 Oct 2005 13:46:15 GMT</pubDate></item><item><title><![CDATA[Reply to sockets: Serverantwort komplett auslesen on Sun, 23 Oct 2005 15:32:57 GMT]]></title><description><![CDATA[<p>Danke für die Antwort,<br />
aber recv() liefert 0 zurück, wenn die Verbindung getrennt worden ist,<br />
was aber nicht der Fall ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/899394</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/899394</guid><dc:creator><![CDATA[anonymus]]></dc:creator><pubDate>Sun, 23 Oct 2005 15:32:57 GMT</pubDate></item><item><title><![CDATA[Reply to sockets: Serverantwort komplett auslesen on Sun, 23 Oct 2005 17:20:12 GMT]]></title><description><![CDATA[<p>Wird die Antwort beim FTP-Protokoll nicht mit irgendwas terminiert (\n\r\n\r oder so?). Dann musst du noch solange recv aufrufen, bis du die Terminierung erhalten hast.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/899469</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/899469</guid><dc:creator><![CDATA[D*niel *chumann]]></dc:creator><pubDate>Sun, 23 Oct 2005 17:20:12 GMT</pubDate></item><item><title><![CDATA[Reply to sockets: Serverantwort komplett auslesen on Sun, 23 Oct 2005 21:49:34 GMT]]></title><description><![CDATA[<p>D@niel $chumann schrieb:</p>
<blockquote>
<p>Wird die Antwort beim FTP-Protokoll nicht mit irgendwas terminiert (\n\r\n\r oder so?). Dann musst du noch solange recv aufrufen, bis du die Terminierung erhalten hast.</p>
</blockquote>
<p>Hab zur Sicherheit grad nochmal Ethereal angeworfen.<br />
Jede Zeile wird mit \r\n terminiert.<br />
Der Serverwelcome hat allerdings mehrere Zeilen.</p>
<p>Mir ist aber grade aufgefallen, dass nur die letzte Zeile der Antwort<br />
ein Leerzeichen nach dem Statuscode hat:</p>
<pre><code>220----------------------------------------------------------------------
220-Welcome on ********************** running Novell NetWare 6.x
220-Please note that passwords are transferred in clear text.
220----------------------------------------------------------------------
220 Service Ready for new User
</code></pre>
<p>Da werd ich mal in dieser Richtung weitersuchen...</p>
<p>thx<br />
Martin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/899645</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/899645</guid><dc:creator><![CDATA[anonymus]]></dc:creator><pubDate>Sun, 23 Oct 2005 21:49:34 GMT</pubDate></item><item><title><![CDATA[Reply to sockets: Serverantwort komplett auslesen on Mon, 24 Oct 2005 09:22:49 GMT]]></title><description><![CDATA[<p>Die Richtung ist gut, ich hab eben mal einen kurzen Blick ins RFC 959 geworfen:</p>
<blockquote>
<p>A reply is defined to contain the 3-digit code, followed by Space &lt;SP&gt;, followed by one line of text (where some maximum line length has been specified), and terminated by the Telnet end-of-line code. There will be cases however, where the text is longer than a single line. In these cases the complete text must be bracketed so the User-process knows when it may stop reading the reply (i.e. stop processing input on the control connection) and go do other things. This requires a special format on the first line to indicate that more than one line is coming, and another on the last line to designate it as the last. At least one of these must contain the appropriate reply code to indicate the state of the transaction. To satisfy all factions, it was decided that both the first and last line codes should be the same.</p>
<p>Thus the format for multi-line replies is that the first line will begin with the exact required reply code, followed immediately by a Hyphen, &quot;-&quot; (also known as Minus), followed by text. The last line will begin with the same code, followed immediately by Space &lt;SP&gt;, optionally some text, and the Telnet end-of-line code.</p>
</blockquote>
<p>( <a href="http://www.freesoft.org/CIE/RFC/959/24.htm" rel="nofollow">http://www.freesoft.org/CIE/RFC/959/24.htm</a> )</p>
]]></description><link>https://www.c-plusplus.net/forum/post/899857</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/899857</guid><dc:creator><![CDATA[D*niel *chumann]]></dc:creator><pubDate>Mon, 24 Oct 2005 09:22:49 GMT</pubDate></item></channel></rss>