[Python-Dev] Return value from socket.fileno() (original) (raw)

Greg Ewing greg.ewing at canterbury.ac.nz
Thu May 24 04:35:05 CEST 2007


Alan Kennedy wrote:

I am writing to seek information about the socket.fileno() method, and opinions on how best to implement it on jython.

I would hope that the new i/o system will make it unnecessary to use fileno() in portable code. It's really a unix-specific thing.

So the question I'm asking is: Does anyone know of existing cpython code which relies on the return value from socket.fileno() being an integer? Or code that would break if it were returned a socket instance instead of an integer?

If you only pass it to other things supported on that platform that use filenos, probably not.

BTW, you can pass socket objects directly to select() anyway. I'd regard this as the current portable way to use sockets and select. The man page says that this works via the fileno() method, but it doesn't have to be implemented that way -- select() could be taught to recognise socket objects natively.

-- Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | Carpe post meridiem! | Christchurch, New Zealand | (I'm not a morning person.) | greg.ewing at canterbury.ac.nz +--------------------------------------+



More information about the Python-Dev mailing list