Skip to content

create_tcp_listener(local_port=0): return listeners with the same port #857

@gschaffner

Description

@gschaffner

Things to check first

  • I have searched the existing issues and didn't find my feature already requested there

Feature description

it would be nice if multilistener = await create_tcp_listener(local_port=0) used the same port for both of the listeners. This would be [implemented via something roughly] like

def get_free_ipv4_ipv6_port(kind, bind_ipv4_addr, bind_ipv6_addr):
    if platform_has_dualstack and bind_ipv4_addr == bind_ipv6_addr == "":
        # We can use the dualstack_sock.bind(("", 0)) trick
        ...
    else:
        ...

Currently, folks who need this have to implement it downstream.)

Ow, that's definitely something I would like to fix! Strange that nobody has reported that as an issue. I definitely meant for the listener to bind to the same ephemeral port if the local port was omitted.

Originally posted by @agronholm in #856 (comment)

Use case

.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions