> This is what I've got right now:
>
> #! /usr/bin/env python
> import socket, string
> sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> def doconn():
>      sock.connect(("localhost", 1234))
> def dodiscon():
>      sock.close()
>      doconn()
>
> doconn()
>
> 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. It does not mean that you have been disconnected. This is 
especially true when you do nothing but recv, recv, recv() in an 
infinite loop.

I recommend that you use select.select to see if there is some data that 
can be read. Call socket.recv() only when you know that it will not fail.

Best,

   Laszlo

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to