From: "Iñaki Baz Castillo" Date: 2010-01-13T08:37:32+09:00 Subject: Re: TCPSocket doesn't detect remote disconnection inmediatelly [SOLVED] El Miércoles, 13 de Enero de 2010, Aaron Turner escribió: > > Is there a way to detect it in Ruby using TCPSocket? if there some > > attribute of the socket object that changes whe such ACK+FIN arrives? > > (however I've tried most of the TCPSocket methods and found nothing). > > There are two ways of doing this: > > 1) The application running over TCP. In this case the HTTP 400 error > is telling you that the web server is done talking to you and no > future requests will be processed. I'm not talking with a HTTP server, but with a SIP server. When the SIP server restarts its sends a TCP packet with FIN flag to me (Ruby client). > 2) The other way is when you read, did you get an EOF error? EOF == > server has called shutdown() on the socket. I have good news for myself :) I've a thread reading the responses received in the socket: sip_response = @@socket.readline("\r\n\r\n") I use "\r\n\r\n" (double CRLF) as a SIP response with no body ends with CRLF CRLF (as HTTP I think). However when the remote disconnects I didn't get the exception EOFError. The very good new is that it's a bug in my code! In the rescue block I did a typo so I wasn't invoking the reconnection command :) Really thanks for the good help received in this thread :) -- Iñaki Baz Castillo