No error while sending via TCP Socket

Ben Sizer kylotan at gmail.com
Mon Jul 3 05:25:26 EDT 2006


Grant Edwards wrote:
> On 2006-06-30, Martin Bürkle <buerklma at web.de> wrote:
>
> > 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
>
> Because send() has successfully passed the packet to the
> network stack.  If you want to know whether the application on
> the other end received it, you need an application-layer
> protocol that acknowleges the data.
>
> > and give me a hint how to get an exception
>
> You can't -- unless you've enabled the keepalive option on the
> TCP connection and you've waited the requisite time after the
> cable is cut before sending your data (IIRC it takes a couple
> hours for an idle TCP connection to time out because of a link
> being down).
>
> TCP/IP is designed to be fault-tolerant.  Temporary breaks in
> cables aren't supposed to cause failures.

But surely a permanent break - which is what I believe was implied -
means the data never arrives, which in turn means you never get an ack,
and eventually the TCP connection should drop, and Python should raise
an exception. Right? I'm very used to connections dropping after much
less than a minute because the host became unreachable or took too long
to send a response.

(Sorry for the large quote but all the context seemed relevant.)

-- 
Ben Sizer




More information about the Python-list mailing list