From: Doug Jolley Date: 2010-06-19T05:01:03+09:00 Subject: Re: Socket Problems > But the main problem is that socket.read will block until the other end > drops the connection. You probably want socket.gets instead. Great suggestion. The problem seems to be that the xml returned by the host (which is php based) is not terminated with a new line. In fact, the returned xml contains no new lines at all. Consequently, using gets produces the same result as using read. I'm thinking that the reason I'm having problems using Ruby to interface via a socket to a PHP based host is that each of the socket implementations in these two languages has slightly different expectations about the protocol being used to transmit the data. I'm not sure what the exact differences are. As you say, it does definitely seem that I am hung waiting for something while the PHP implementation seems to somehow know when the host is through transmitting the data. This hypothesis is supported by the fact that if I use readpartial and set the number of bytes to some low value less than the length of the data expected to be returned, I get a snappy response with the expected bytes of data. Also of interest is the fact that I can use telnet to interface to the PHP host and get a full response immediately. So, apparently telnet also knows how to tell when the host is through transmitting data. I'm kind of surprised that there isn't more chatter on this issue. I would think that it would have been frequently encountered by many others before me. I do know that it's a BIG problem for me and I really need to find a fix. > Aside: port is usually an integer not a string (unless you're > giving a service name from /etc/services) My bad. An integer obviously correct. Thanks to all for the input. If anyone has any further ideas, I'd sure like to hear them. ... doug -- Posted via http://www.ruby-forum.com/.