how to know if socket is still connected
nephish at xit.net
nephish at xit.net
Sun Jul 16 23:37:57 EDT 2006
cool enough, thanks !
-sk
Grant Edwards wrote:
> On 2006-07-16, nephish at xit.net <nephish at xit.net> wrote:
>
> >> If the server has closed the connection, then a recv() on the
> >> socket will return an empty string "", and a send() on the
> >> socket will raise an exception.
>
> > like this ?
> > databack = aeris_sockobj.recv(2048)
> > if databack:
> > view_msg = 'caught request acknowlage %s bytes \n' %
> > len(databack)
> > else:
> > view_msg = 'fail to recieve data from aeris server\n'
> >
> > then put the reconnect in the else: block ?
>
> Yes, if the problem is that the host closes the connection,
> that should work. Modulo the broken indentation and
> line-wrapping. ;)
>
> --
> Grant Edwards grante Yow! My mind is a potato
> at field...
> visi.com
More information about the Python-list
mailing list