From: Gary Wright Date: 2011-09-08T04:34:47+09:00 Subject: Re: TCPSocket recv's nil with gets() if the server crashes? On Sep 7, 2011, at 1:50 PM, Eric Wong wrote: > The problem with IO#gets is that it can still hang indefinitely if the > server sent an incomplete line. select() will wake up from one byte > of data, but the server could've had its connection truncated before > the rest of the line reached you. In additional to worrying about a server failing, you must always worry about the network silently failing. It may be that the server is up, has transmitted a full line of text but that the line straddled two network segments with the first segment making it successfully to the client but the second segment being lost in the network. Subsequent retransmissions might fail for a long time before succeeding and so the client is left with a partial line of text for an indefinite amount of time (thus the need to incorporate some sort of application level timeout). Gary Wright