Send all packets (socket programming)

Tomas Christiansen toc-01-nospam-removethisword at blikroer.dk
Sun May 22 16:48:45 EDT 2005


Is there a way to make shure that all packets has been sent before issuing 
a Shutdown and/or Close on a (TCP) Socket?

The problem is that "the other end" interprets a reset-flag (RST) on an IP-
packet as an indication of an error. Instead the finish-flag (FIN) must be 
set, in order to close the connection non-errornously. That can be achieved 
by using socket.shutdown(SHUT_RDWR) followed by socket.close().

BUT if all data has not been sent, sometimes shutdown(SHUT_RDWR) followed 
by close(), sets RST, and the other end thinks that something went wrong 
(the other end is some unknown TCP/IP printer) and goes to an error-state.

-------
Tomas



More information about the Python-list mailing list