"Just Another Victim of the Ambient Morality" <ihatespam / hotmail.com> wrote in message news:%Qkvl.43684$Yx2.7782 / en-nntp-06.dc1.easynews.com... > I have the following Ruby program: > > > sock = TCPSocket.new('host.com', 12345) > > sock.write('This is a test') > > data = sock.read(1024) > puts data > > > ...The service this connection connects to just reads the string and > write a response which this program then tries to read. I expected it to > just work but instead it just hangs. The weird part is that it hangs > before the data is actually written out through the socket. The service > on the other end doesn't get any data. If I remove the end part of the > program that attempts to read the response, the data makes it through and > is read correctly by the service. > What is wrong with my program? Why is it hanging? > Thank you... Okay, I can shed some more light on this problem. If the service I'm connecting to is the first one to send data and my program reads that data like so: sock = TCPSocket.new('host.com', 12345) line = sock.readline puts line ....even if the service sends several lines, sock.readline won't return until the connection is closed. This sounds like it may be a bug specific to the Win32 implementation of Ruby 1.8 but that's just a guess. Does anyone know what's going on here? Thank you...