Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync-serve doesn't detect ipv6 addresses #1570

Closed
tamo opened this issue Jan 7, 2025 · 3 comments
Closed

sync-serve doesn't detect ipv6 addresses #1570

tamo opened this issue Jan 7, 2025 · 3 comments
Labels

Comments

@tamo
Copy link

tamo commented Jan 7, 2025

Thanks for the great product!
I'd like to report a minor issue I just faced.

I need to listen on an ipv6 address.
asyncio version can simply serve("::", port)
but sync version needs specifying the family like

with serve(handler, "::", port, family=socket.AddressFamily.AF_INET6) as server:
  server.serve_forever()
@aaugustin
Copy link
Member

While I care about consistency between the asyncio and threading implementation, I care about consistency with Python's stdlib even more, and this behavior is inherited from the standard library.

>>> import socket
>>> socket.create_server(("::", 1234))
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    s = socket.create_server(("::", 1234))
  File "/Users/myk/.pyenv/versions/3.13.1/lib/python3.13/socket.py", line 947, in create_server
    raise error(err.errno, msg) from None
OSError: [Errno 8] nodename nor servname provided, or not known (while attempting to bind on address ('::', 1234))
>>> socket.create_server(("::", 1234), family=socket.AddressFamily.AF_INET6)
<socket.socket fd=5, family=30, type=1, proto=0, laddr=('::', 1234, 0, 0)>

This should be improved in Python, perhaps by changing the default to family=AF_UNSPEC like asyncio.create_server and making it work. I recommend that you file an issue against Python.

@aaugustin
Copy link
Member

Thank you for reporting this issue anyway!

@tamo
Copy link
Author

tamo commented Jan 13, 2025

Fair enough. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants