From: Nathan Taylor Date: 2007-01-04T04:09:35+09:00 Subject: Re: how to properly format data when using TCPSocket.send() > I tried using "\r\n\r\n", but I'm still having some problems due to the > way the HTTP protocol uses multiple TCP sessions and my lack of > understanding on how to handle that with Net::TCPSocket. I just wanted to add some comments about using TCPSocket that might help others as myself. I found out that the problem I was having with TCPSocket was a problem with the closing of the session. I was sending some data to craft an HTTP SEARCH request using the format client = TCPSocket.new(host, 80); data = "SEARCH /vroot/folder/ HTTP/1.1 Content-Type: text/xml Content-Length: 253 Host: server.tld SELECT \"DAV:contentclass\", \"DAV:displayname\" FROM \"/vroot/folder/\" WHERE \"DAV:ishidden\" = false AND \"DAV:isfolder\" = false " client.send(data, 0) response = client.recvfrom(1024) puts response client.close However this would just cause the script to hang at the command line and the web server would never send it's response until I sent an interrupt to the running script. I realized through some tcpdump magic that the web server would send the response after I killed the script so I modified the end of the code to; client.send(data, 0) client.shutdown( how=1 ) response = client.recvfrom(1024) puts response client.close It works.. Everyone's happy. This is just an FYI for anyone running in to a similar problem implementing a network client, sorry for the verboseness. - Nathan -- Posted via http://www.ruby-forum.com/.