[Gllug] poll() & python
ab
ajb at spkypc.demon.co.uk
Tue Nov 27 13:59:53 UTC 2001
Hey,
Anyone using Python out there ?
Try to do asynchronous I/O on a socket... using the poll() system call
(reading the man page it says that poll is more efficient than select).
However once connection is made, it always returns data ready to be
read (POLLIN flag), and always returns immediately with no timeout.
The client has hungup already and reading gives 0 bytes ??????
Sample code:
poller.register(conn.fileno(),select.POLLIN | select.POLLERR
| select.POLLHUP | select.POLLNVAL)
while 1:
result = poller.poll(5000)
if result == []:
break
fd,event = result[0]
if event == select.POLLIN:
str = conn.recv(1024)
print len(str)
print str
else:
break
poller.unregister(conn.fileno())
Anyone used poll before ? its got me foxed !
/Anthony/
--
Gllug mailing list - Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug
More information about the GLLUG
mailing list