Sockets question

Martin von Loewis loewis at
Thu Aug 9 14:08:44 CEST 2001

"frank booth" <killingjoke at> writes:

> 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.

The system won't wait indefinitely to transmit all data.

> 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).

I would really recommend to set the SO_LINGER option on the socket. In
that case, close will wait until the connection has been shut down (or
until the linger interval is reached).


More information about the Python-list mailing list