Skip to content

UDP: provide a way to figure out a port that is not yet listened on #496

@hannesm

Description

@hannesm

@reynir mentioned in mirage/ocaml-dns#322 (review):

I am a little concerned that generate_udp_port doesn't check that nothing is listening on the generated port. The interface of UDP.listen always replaces an existing listener. An application that uses DNS and listens on UDP may eventually break because a dns lookup triggered generate_udp_port to generate the application port. However, with the current interface I can't see how we can do better.

I suggested: maybe as simple as providing a free_port in the interface. But indeed it may be a bit more tricky to avoid TOCTOU. Maybe there should instead be a listen that outputs a port (and allows a range being specified).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions