Socket Disconnection

Guyon Morée gumuz at
Mon Jun 24 10:13:35 CEST 2002

ok, thanx a lot!

what do you mean by an empty datastring? does it, before disconnecting, send
a "" or none?

and for the case of abrupt(hardware) disconnecting, should i use a 'try:' or
does this not have any effect?



"Andrae Muys" <amuys at> wrote in message
news:7934d084.0206232354.52c2163d at
> "Colin Brown" <cbrown at> wrote in message
news:<3d16817e$1 at>...
> > Hi Guyon
> >
> > I assume here that you are talking TCP/IP.
> >
> > If you are waiting on a receive [ data = connection.recv() ] then you
> > have an empty data string returned when the client disconnects.
> >
> > If you are sending you will get an error telling you the link was shut
> >
> Also note that the only reliable way to detect a client disconnect is
> the latter.  If you want to demonstrate the failure of the recv()
> approach, just yank out the ethernet cable on the client machine, and
> notice that although the client is now disconnected, the server has no
> idea.
> Might I suggest taking a look at TCP/IP Illustrated Vol 1, by
> W.Richard Stevens.  Definately a book to read if you are doing any
> TCP/IP network programming.
> Andrae Muys

More information about the Python-list mailing list