time out socket

Martin von Loewis loewis at informatik.hu-berlin.de
Sun Mar 17 12:59:51 EST 2002


"Billy Ng" <evebill8 at hotmail.com> writes:

> Would anybody please tell me how time out the socket.connect() if
> the host does not exists or is unable to connect, thanks!

The connect call will time out eventually on its own, after the
operating system's timeout has passed.

If you want to shorten the timeout, and you have a Posixish system,
you can set an alarm using signal.alarm. Make sure you install a
signal handler; it does not need to do anything since the connect will
raise EINTR.

Regards,
Martin




More information about the Python-list mailing list