How do I reconnect a disconnected socket?
Grant Edwards
grante at visi.com
Fri Mar 28 12:13:34 EDT 2008
On 2008-03-28, Laszlo Nagy <gandalf at shopzeus.com> wrote:
>> while (1):
>> buffer = sock.recv(1024)
>> if not buffer:
>> dodiscon()
>>
>
> sock.recv(1024) can return zero bytes of data indicating that no data
> arrived yet.
No, it can't.
> It does not mean that you have been disconnected.
Yes, that is exactly what it means.
>From the recv() man page:
RETURN VALUE
These calls return the number of bytes received, or -1 if an error
occurred. The return value will be 0 when the peer has performed an
orderly shutdown.
--
Grant
More information about the Python-list
mailing list