Ned:
>>> socket.gethostbyname("localhost")
'127.0.0.1'
>>> socket.getaddrinfo("localhost", "00", 0, 0, 0, socket.AI_NUMERICSERV)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/socket.py", line 530, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
And to show that using AI_NUMERICSERV isn't *completely* broken on my machine:
>>> socket.getaddrinfo("localhost", "80", 0, 0, 0, socket.AI_NUMERICSERV)
[(<AddressFamily.AF_INET: 2>, <SocketType.SOCK_DGRAM: 2>, 17, '', ('127.0.0.1', 80)), (<AddressFamily.AF_INET: 2>, <SocketType.SOCK_STREAM: 1>, 6, '', ('127.0.0.1', 80)), (<AddressFamily.AF_INET6: 30>, <SocketType.SOCK_DGRAM: 2>, 17, '', ('::1', 80, 0, 0)), (<AddressFamily.AF_INET6: 30>, <SocketType.SOCK_STREAM: 1>, 6, '', ('::1', 80, 0, 0)), (<AddressFamily.AF_INET6: 30>, <SocketType.SOCK_DGRAM: 2>, 17, '', ('fe80::1%lo0', 80, 0, 1)), (<AddressFamily.AF_INET6: 30>, <SocketType.SOCK_STREAM: 1>, 6, '', ('fe80::1%lo0', 80, 0, 1))] |