From: Bill Kelly Date: 2005-09-08T14:18:29+09:00 Subject: Re: Nonblocking and/or win32 From: "Morgan" > (I could use recv with > a number larger than anything I should ever have waiting for an argument, > but that's crude. Just curious why that would seem crude. It's my understanding that's why recv() behaves as it does. The following is untested, but is similar to what I've written many times: def TCPSocket.read_all_available buf = "" while select([self], nil, nil, 0) dat = self.recv(65536) rescue nil break unless dat && ! dat.empty? buf << dat end buf end Usually instead of just a "break", I'll set an "eof" flag when I get a nil (or an exception) back from recv(). (Note that select() will indicate that a socket is 'readable' if it's at EOF, but then recv() returns nothing and/or an exception... as I recall... Thus the above 'rescue nil' followed by checking for no data returned.) But anyway . . . Hope this helps, Regards, Bill