how to detect connection closed by server?
sc0rp at hot.pl
Wed Mar 24 08:36:41 CET 2004
Joe Wong wrote:
> 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?
Yes. You cannot tell how much of incoming data server read before
calling close(). Whether server sent some reply or not is irrelevant.
There is nothing that prevents server from accepting conncection,
sending some reply and closing conn without bothering to read incoming
data at all or after reading only part of it.
> 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..
If server deliberately decides to not read data till EOF or for example
server app is killed before it can read all data, the only notification
you will get on client, will be that connection has been closed from the
More information about the Python-list