Socket Disconnection

Guyon Morée gumuz at looze.net
Mon Jun 24 04:13:35 EDT 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?

thanx,

Guyon

"Andrae Muys" <amuys at shortech.com.au> wrote in message
news:7934d084.0206232354.52c2163d at posting.google.com...
> "Colin Brown" <cbrown at metservice.com> wrote in message
news:<3d16817e$1 at news.nz.asiaonline.net>...
> > Hi Guyon
> >
> > I assume here that you are talking TCP/IP.
> >
> > If you are waiting on a receive [ data = connection.recv() ] then you
will
> > 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
down.
> >
>
> 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