Skip to content

Binding to both IPv4 and IPv6 for a given host on an available port #160

Description

@pquentin

I'm migrating the urllib3 test suite from Tornado to Hypercorn.

The default behavior of Tornado, when given a host such as localhost is to bind to both IPv4 (127.0.0.1) and IPv6 (::1). An additional wrinkle is that we're using port zero to get an available port, which means we need a retry loop to avoid the situation where one port is free in IPv4 but not in IPv6, which happens from time to time in CI.

This behavior is quite handy, because it allows us to test urllib3 source_adress support. This is different from #85 which is about binding to IP addresses directly.

Since this is quite a niche use case, would you accept a pull request to expose sockets from hypercorn.trio.serve? worker_serve already accepts such a parameter, so that would be a one-line change (two-line to add asyncio support).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions