Sockets question

Steve Holden sholden at
Thu Aug 9 13:54:31 CEST 2001

"frank booth" <killingjoke at> wrote in message
news:mailman.997349655.23903.python-list at
> Howdy.
> I'm sending something through a TCP socket, then closing it, then my
python script exits.
> For some reason, from time to time (and not on all machines) the remote
end doesn't always get the data.
> I thought close() is supposed to terminate the connection gracefully so it
should be OK, but its not.
> Maybe when the script exits the connection dies at once? Is there a simple
solution that will not involve waiting? (its used in a high-load system so I
should free the socket and leave the process as quickly as possible. It is
also impossible to change the remote program).
The TCP layer should not lose data just because you close a socket, as long
as you are using a correct call sequence. Perhaps the problem lies in an
application-layer incompatibility?

The only way to really find out what is going on is to trace the packets
going between your machine and the remote one. THis gives you accurate data
about the traffic, whcih is usually helpful. Ethereal is an open source
product that will let you do packet traces on Windows or Unixen (you don't
say which platform you are using). See

for more data. If this is going to farr for your taste, perhaps you could
post your code? Since you don't even say what the application protocol is
it's hard top be more specific.


More information about the Python-list mailing list