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

Guido van Rossum guido at python.org
Thu May 24 04:52:09 CEST 2007


On 5/23/07, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> 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.

I want to emphasize this option. Passing the socket to select should
be more portable than using fileno().

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list