Problem with socket
Donn Cave
donn at u.washington.edu
Wed Apr 28 14:11:43 EDT 2004
In article <408f7917$0$27016$626a14ce at news.free.fr>,
Thomas Herve <therve at neocles.com> wrote:
...
> Ok I hope it's clear. My problem is that "select" only tests if there's
> data on the socket, and not the state of the socket. I want to be able
> to know if socket is "alive" or something like that. But I don't want
> to make "send" in the client (stay passive). Then, if I know that my
> socket is closed or my link down, I can try to reconnect periodically.
Try a SO_KEEPALIVE option on the socket (setsockopt). That
should (I would sort of expect anyway) raise an exception when
the keepalive negotiation fails. The reaction won't be immediate,
it may take hours to notice a dead connection.
Donn Cave, donn at u.washington.edu
More information about the Python-list
mailing list