[issue27377] Add smarter socket.fromfd()

Martin Panter report at bugs.python.org
Sun Jul 17 19:52:53 EDT 2016


Martin Panter added the comment:

The Windows problem, error 10022 = WSAEINVAL from getsockname(), seems to be documented at <https://msdn.microsoft.com/en-us/library/windows/desktop/ms738543%28v=vs.85%29.aspx>: “The socket has not been bound”.

Regarding the SCTP problem, raising an error seems like an OS bug to  me. However, according to POSIX <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockname.html>, we cannot rely on getsockname() indicating any particular address family if the socket is unbound.

So on some platforms, it seems like it will only work with bound sockets, or you have to use less-standard options like SO_PROTOCOL_INFO or SO_DOMAIN. Although SO_DOMAIN won’t help on Free BSD. The simplest solution may be to document and test that it only works with bound sockets.

For the problem with SO_PROTOCOL being unsupported at run-time, I think it would be better to anticipate EINVAL now, rather than wait for someone to complain. But it is not a big deal.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27377>
_______________________________________


More information about the Python-bugs-list mailing list