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 twisteroid ambassador
Recipients asvetlov, eamanu, lepaperwan, maxifree, twisteroid ambassador, yselivanov
Date 2019-01-04.08:01:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1546588892.74.0.559545613315.issue35545@roundup.psfhosted.org>
In-reply-to
Content
I just noticed that in the socket module, an AF_INET address tuple is allowed to have an unresolved host name. Quote:

A pair (host, port) is used for the AF_INET address family, where host is a string representing either a hostname in Internet domain notation like 'daring.cwi.nl' or an IPv4 address like '100.50.200.5', and port is an integer.

https://docs.python.org/3/library/socket.html#socket-families

Passing a tuple of (hostname, port) to socket.connect() successfully connects the socket (tested on Windows). Since the C struct sockaddr_in does not support hostnames, socket.connect obviously does resolution at some point, but its implementation is in C, and I haven't looked into it.

BaseSelectorEventLoop.sock_connect() calls socket.connect() directly, therefore it also supports passing in a tuple of (hostname, port). I just tested ProactorEventLoop.sock_connect() on 3.7.1 on Windows, and it does not support hostnames, raising OSError: [WinError 10022] An invalid argument was supplied.

I personally believe it's not a good idea to allow hostnames in address tuples and in sock.connect(). However, the socket module tries pretty hard to basically accept any (host, port) tuple as address tuples, whether host is an IPv4 address, IPv6 address or host name, so that's probably not going to change.
History
Date User Action Args
2019-01-04 08:01:33twisteroid ambassadorsetrecipients: + twisteroid ambassador, asvetlov, yselivanov, lepaperwan, eamanu, maxifree
2019-01-04 08:01:32twisteroid ambassadorsetmessageid: <1546588892.74.0.559545613315.issue35545@roundup.psfhosted.org>
2019-01-04 08:01:32twisteroid ambassadorlinkissue35545 messages
2019-01-04 08:01:32twisteroid ambassadorcreate