[issue16802] fileno argument to socket.socket() undocumented

Richard Oudkerk added the comment:
The "fileno" argument looks like an implementation detail to me.
It has at least one potential use. On Windows socket.detach() returns a socket handle but there is no documented way to close it -- os.close() will not work. The only way to close it that I can see (without resorting to ctypes) is with something like socket.socket(fileno=handle).close() ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16802> _______________________________________

Serhiy Storchaka added the comment:
It has at least one potential use. On Windows socket.detach() returns a socket handle but there is no documented way to close it -- os.close() will not work. The only way to close it that I can see (without resorting to ctypes) is with something like
socket.socket(fileno=handle).close()
There is an alternative (documented) interface: socket.fromfd(handle, socket.AF_INET, socket.SOCK_STREAM).close() ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16802> _______________________________________
participants (2)
-
Richard Oudkerk
-
Serhiy Storchaka