Non blocking sockets with select.poll() ?

Maxim Veksler hq4ever at gmail.com
Fri May 4 06:04:41 EDT 2007


Hi,

I'm trying to write a non blocking socket port listener based on
poll() because select is limited to 1024 fd.

Here is the code, it never gets to "I did not block" until I do a
telnet connection to port 10000.

"""
#!/usr/bin/env python
import socket
import select

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setblocking(0)
s.bind(('0.0.0.0', 10000))
s.listen(5)

__poll = select.poll()
__poll.register(s)
__poll.poll()

print "I did not block"
"""

-- 
Cheers,
Maxim Veksler

"Free as in Freedom" - Do u GNU ?



More information about the Python-list mailing list