No error while sending via TCP Socket

Laszlo Nagy gandalf at
Fri Jun 30 11:45:22 CEST 2006

Martin Bürkle írta:
> Hi NG,
> I have writen a programm using TCP sockets. After i get the connection 
> to another socket I cut the Ethernet cable. Then I send a message.
> The program doesnt raise any exception. Can somebody tell me why and 
> give me a hint how to get an exception
Okay, let's suppose you do not cut the ethernet cable and your message 
arrives on the other side, but the receiver program has a problem (not 
enough memory, bug in the handling code etc.) so your message is not 
processed on the other side. Most of the time, you do not only want to 
check if your message was transferred - you also need to check if that 
is actually processed. The TCP protocol cannot do this for you.Your 
clients needs to send back another message that notifies the sender 
about successful processing. Your sender program can wait for this 
notification, and then raise an exception after some timeout.

In other words, you need to develop your own communication protocol over 
TCP/IP. You should try to minimize the number of 
send-receive-notification cycles, because the answer time can be high, 
compared to the transfer speed of the communication channel. And also 
because notifications are usually small, and they a buffered for a 
while... I have seen a paper about designing protocols over TCP/IP, but 
I do not remember now. Others will help you for sure.

Please also consider UDP (if possible), which can be much more efficient.



More information about the Python-list mailing list