how to detect connection closed by server?

Joe Wong joewong at mango.cc
Tue Mar 23 23:11:34 EST 2004


Hi there, I have a simple TCP client server program to perform the following:

Server:
- create socket
- bind socket to some port
- listen
- accept connection
- read data from client socket
- close the socket

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 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? I am using python 2.1.3 on Linux but I tried also 2.3.3 with same behaviour.

Best regards,

- Wong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20040324/e31bd697/attachment.html>


More information about the Python-list mailing list