This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Paul McGuire
Recipients Paul McGuire, gvanrossum, vstinner, yselivanov
Date 2016-08-21.10:40:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1471776053.58.0.243290742982.issue27822@psf.upfronthosting.co.za>
In-reply-to
Content
In writing a simple UDP client using asyncio, I tripped over a call to getsockname() in the _SelectorTransport class in asyncio/selector_events.py.


    def __init__(self, loop, sock, protocol, extra=None, server=None):
        super().__init__(extra, loop)
        self._extra['socket'] = sock
        self._extra['sockname'] = sock.getsockname()

Since this is a sending-only client, the socket does not get bound to an address. On Linux, this is not a problem; getsockname() will return ('0.0.0.0', 0) for IPV4, ('::', 0, 0, 0) for IPV6, and so on. But on Windows, a socket that is not bound to an address will raise this error when getsockname() is called:

    OSError: [WinError 10022] An invalid argument was supplied

This forces me to write a wrapper for the socket to intercept getsockname() and return None.

In asyncio/proactor_events.py, this is guarded against, with this code in the _ProactorSocketTransport class:

        try:
            self._extra['sockname'] = sock.getsockname()
        except (socket.error, AttributeError):
            if self._loop.get_debug():
                logger.warning("getsockname() failed on %r",
                             sock, exc_info=True)


Please add similar guarding code to the _SelectorTransport class in asyncio/selector_events.py.
History
Date User Action Args
2016-08-21 10:40:53Paul McGuiresetrecipients: + Paul McGuire, gvanrossum, vstinner, yselivanov
2016-08-21 10:40:53Paul McGuiresetmessageid: <1471776053.58.0.243290742982.issue27822@psf.upfronthosting.co.za>
2016-08-21 10:40:53Paul McGuirelinkissue27822 messages
2016-08-21 10:40:53Paul McGuirecreate