Take the 2-minute tour ×

I more or less know how to use select() to take a list of sockets, and only return the ones that are ready to read/write something. The project I'm working on now has a class called 'user'. Each 'user' object contains its own socket. What I would like to do is pass a list of users to a select(), and get back a list of only the users where user.socket is ready to read/write. Any thoughts on where to start on this?

Edit: Changed switch() to select(). I need to proofread better.

share|improve this question
Do you mean select? –  Dustin Jan 12 '10 at 5:36

1 Answer 1

up vote 2 down vote accepted

You should have your User class implement a fileno(self) method which returns self.thesocket.fileno() -- that's the way to make select work on your own classes (sockets only on windows, arbitrary files on Unix-like systems). Not sure what switch is supposed to me -- don't recognize it as a standard library (or built-in) Python concept...?

share|improve this answer

Your Answer


