[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaSocket - how can a tcp client detect a closed connection?
- From: Javier Guerra <javier@...>
- Date: Thu, 1 Mar 2007 17:03:10 -0500
On Thursday 01 March 2007, Romulo Bahiense wrote:
> The problem is: how to detect when the server (httpd: apache+fastcgi)
> closes the connection? I've tried to watch the results of client:send()
> while sending the reqline and detecting if the error is "closed", but it
> seems that the client is acting as if nothing had happened until it
> tries to read from the same socket.
this is the expected behaviour, by definition calling close() on a TCP stream
only means "i won't write anymore data to this stream". it's perfectly valid
to keep reading for as long as you want.
so, if the server closes the stream you can still send data; and if it calls
read(), will get it. only when the second part (the client, in your case)
calls close() too, is the whole stream finished.
now, should it be detectable by the application?... i have no idea
--
Javier
Attachment:
pgp6Imu2j5OtT.pgp
Description: PGP signature