Muliplexing Socket Connections

Nathan Cassano nathan at cjhunter.com
Mon Apr 23 13:27:19 EDT 2001


Hello Pythoneers,
    I'm developing a socket server that needs to bind to and multiplex multiple
ports. I'm using the select module and sockets to do this. The problem is I
cannot get the select function to return a file descriptor from it's return read
list. Does anyone have a simple example of socket multiplexing or some pointers?

import socket, select

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.setblocking(0)

print select.select([sock],[sock] ,[] , 0)

...

This is the output that follows

([], [<socket object, fd=3, family=2, type=1, protocol=0>], [])





More information about the Python-list mailing list