The telnet protocol states that telnet delimits lines with &quot;\r\n&quot;, so just by keyboard input, it would be very difficult if not impossible to send &quot;\n.\n&quot; to make sure that ending condition is checked.<br>

One way to get around this would be to replace all instances of &quot;\r\n&quot; with &quot;\n&quot; on the server-side.  Another solution would be to use a program called &quot;netcat&quot;, which is like telnet but with a few important differences.  One difference is that it sends &quot;\n&quot; at the end of lines.<br>

<br>Netcat is a UNIX utility, but there are ports for POSIX, Darwin, and Windows.<br><br>--Joe<br><br><div class="gmail_quote">On Sat, Sep 26, 2009 at 10:26 PM, C. Titus Brown <span dir="ltr">&lt;<a href="mailto:ctb@msu.edu">ctb@msu.edu</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi all,<br>
<br>
a few notes on the echo servers (p2 and p3 in the homework).<br>
<br>
First, a \n followed by a . followed by a \n should close both echo<br>
servers, independently of when those characters arrive.  They may be<br>
spread across multiple recv calls, in particular.  You can test this<br>
effectively by changing your server to do &#39;sock.recv(1)&#39; instead of<br>
4096.<br>
<br>
Second, very important point on the non-blocking server: sockets<br>
returned by &#39;accept()&#39; are &quot;new&quot; and do not inherit non-blocking status<br>
from their parent bound sockets.  e.g. in the HW, &#39;client_sock&#39; would be<br>
set to blocking independently of the blocking status of &#39;sock&#39;.<br>
<br>
Third, the non-blocking echo server should accept connections at any<br>
time, process as many connections as possible (&gt; 2, in other words),<br>
and discard closed socket connections from the list of connections to<br>
process.<br>
<br>
Fourth, &#39;telnet&#39; simply connects to the specified host/port and sends<br>
whatever text you type to that host/port.  It&#39;s a good way to test some<br>
basic functionality because it doesn&#39;t require you to program a client<br>
in order to test a server.<br>
<br>
--titus<br>
<font color="#888888">--<br>
C. Titus Brown, <a href="mailto:ctb@msu.edu">ctb@msu.edu</a><br>
<br>
_______________________________________________<br>
cse491-fall-2009 mailing list<br>
<a href="mailto:cse491-fall-2009@lists.idyll.org">cse491-fall-2009@lists.idyll.org</a><br>
<a href="http://lists.idyll.org/listinfo/cse491-fall-2009" target="_blank">http://lists.idyll.org/listinfo/cse491-fall-2009</a><br>
</font></blockquote></div><br>