From: ts Date: 2002-04-29T01:53:10+09:00 Subject: Re: Inconsistent network behaviour >>>>> "F" == Farrel Lifson writes: F> When I run it on a FreeBSD box (FreeBSD 4.4,Ruby 1.6.3) the output is: F> Data read: me@foo.com F> To: you@bar.com Well I've the same result on a linux box (2.4.14) and its normal #recv(len) try to read a maximum of len data from the socket. F> The program reads the two lines (sent using two seperate send method F> calls) in with one recv, as well as the final "\r\n" which causes it to F> then go into an infinite loop (printing out Data read: Data read: Data F> read: ...) as it keeps on reading in from the socket even though it is F> closed on the client side. This just mean that all data was available when you have called #recv F> This is a simple exercise so I'm sure there's a solution, just that I F> can't find anything in the pickaxe book or online docs. Any ideas what F> the problem is and why the behaviour is different on Linux and FreeBSD? You have an example of TCPServer at http://www.ruby-lang.org/en/man-1.4/socket.html#TCPServer and you'll see that it use #gets another example for the client http://www.ruby-lang.org/en/man-1.4/socket.html#TCPSocket where #write is used Guy Decoux