The telnet protocol states that telnet delimits lines with "\r\n", so just by keyboard input, it would be very difficult if not impossible to send "\n.\n" to make sure that ending condition is checked.<br>
One way to get around this would be to replace all instances of "\r\n" with "\n" on the server-side. Another solution would be to use a program called "netcat", which is like telnet but with a few important differences. One difference is that it sends "\n" 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"><<a href="mailto:ctb@msu.edu">ctb@msu.edu</a>></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 'sock.recv(1)' instead of<br>
4096.<br>
<br>
Second, very important point on the non-blocking server: sockets<br>
returned by 'accept()' are "new" and do not inherit non-blocking status<br>
from their parent bound sockets. e.g. in the HW, 'client_sock' would be<br>
set to blocking independently of the blocking status of 'sock'.<br>
<br>
Third, the non-blocking echo server should accept connections at any<br>
time, process as many connections as possible (> 2, in other words),<br>
and discard closed socket connections from the list of connections to<br>
process.<br>
<br>
Fourth, 'telnet' simply connects to the specified host/port and sends<br>
whatever text you type to that host/port. It's a good way to test some<br>
basic functionality because it doesn'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>