UDP: provide a way to figure out a port that is not yet listened on
hannesm opened this issue · 0 comments
hannesm commented
@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 ofUDP.listen
always replaces an existing listener. An application that uses DNS and listens on UDP may eventually break because a dns lookup triggeredgenerate_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).