You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It looks like the Python stdlib has a weird behavior:
socket.getaddrinfo(None, 0) resolves to the wildcard address(es)
sock.bind((None, 0)) is an error
socket.getaddrinfo("", 0) is an error
sock.bind(("", 0)) binds to the wildcard address
Trio is currently not quite consistent. Trio's getaddrinfo matches the stdlib, but for bind we raise an error with both versions, because we use getaddrinfo to validate the user's input, and then if it passes we hand the user's input directly to the stdlib bind.
We should at the least support one way of calling bind, and perhaps we should teach both versions to support both behaviors.
The text was updated successfully, but these errors were encountered:
So I guess we probably shouldn't special-case "" in our getaddrinfo implementation, since it technically is a name string you could look up, and it has well-defined behavior in some cases. In particular, on Windows, it returns a list of all currently-configured local interfaces. (Why this is useful, I have no idea. But it's specified to do so.)
So I think we should:
Support None everywhere
Special case "" in our sockaddr resolver routines (but not getaddrinfo) by replacing it with None.
(Fun fact: on Linux getaddrinfo("*", ...) also resolves to the wildcard addresses, exactly like passing None. But this isn't portable, and None is.)