select.epoll question

Chris Angelico rosuav at gmail.com
Thu Feb 7 07:49:00 EST 2013


On Thu, Feb 7, 2013 at 6:08 PM, Paul Rubin <no.email at nospam.invalid> wrote:
> Any idea of a good way to map the file descriptors back to socket
> objects?  Is there some kind of hidden interface that I don't know
> about, that gives back sockets directly?

I don't know of any, but you can get the file descriptor from a socket
via fileno(), and build your own dictionary:

fd_to_sock={sock.fileno():sock for sock in list_of_sockets}

You'd need to manually maintain that as sockets get created/destroyed, though.

ChrisA



More information about the Python-list mailing list