how to detect connection closed by server?

Joe Wong joewong at mango.cc
Wed Mar 24 01:10:43 EST 2004


Hi Jacek,

  If the server never send some reply back to the client, it is not possible
for the client to determine if the server had actually received the data (
e.g., server called accept() but not calling recv() to read data from
client, then close() the client socket right away ). Am I right? If this is
the case, I can't really rely on the socket function in the client program
to tell if the server has read the data..

Regards,

- Wong

----- Original Message ----- 
From: "Jacek Trzmiel" <sc0rp at hot.pl>
To: "Joe Wong" <joewong at mango.cc>
Cc: <python-list at python.org>
Sent: Wednesday, March 24, 2004 1:42 PM
Subject: Re: how to detect connection closed by server?


>
> Joe Wong wrote:
> > Client:
> > - create socket
> > - connect to port XYZ at server
> > - send some data to server
> > - close the socket
> >
> > The problem I found is that, after the server perform the listen()
> > call, the client program can sucessfully perform connect(), send() and
> > close() on the socket
>
> AFAIR with T/TCP it's entriely possible to open connection, send small
> payload and close connection in one single IP packet.
>
> > even the server process does not perform the
> > accept() and recv() call. Is this a general behaviour of the socket or
> > I am not writing my program properly?
>
> Close only sending part of the socket and then block on read.  It will
> either:
> - report EOF if server accepted and then closed connection without
> sending any data,
> - return some data if server sent it,
> - report some kind of error otherwise.
>
> Best regards,
> Jacek.
>
>





More information about the Python-list mailing list