Question about select()
brueckd at tbye.com
brueckd at tbye.com
Fri Sep 27 01:06:46 EDT 2002
On Thu, 26 Sep 2002 sismex01 at hebmex.com wrote:
> Does select() work on bound sockets, to detect
> incoming connections?
>
> I'd like to be able to have a timeout when accepting
> connections from a server socket.
Yes. When the listening socket is readable there is a new socket waiting
to accept:
>>> from socket import *
>>> import select
>>> s = socket(AF_INET, SOCK_STREAM)
>>> s.bind(('127.0.0.1',5555))
>>> s.listen(1)
>>> select.select([s],[],[],1.0)
([], [], [])
>>> select.select([s],[],[],1.0)
([<socket object, fd=3, family=2, type=1, protocol=0>], [], [])
-Dave
More information about the Python-list
mailing list