feat(listener): ListenerQUIC::Port() reads back the port it bound

Port 0 asks msquic for an ephemeral port, but nothing read that port
back, so a QUIC server had to pick a fixed one and hope nothing else held
it, and this suite has to hand every QUIC test a port of its own.
ListenerStart writes the port of the UDP socket it bound into the
listener's local address; the constructor now reads it with
QUIC_PARAM_LISTENER_LOCAL_ADDRESS right after the start, and Port()
returns it. It is valid as soon as the constructor returns and still
after Stop(), and 0 on a moved-from listener. ListenerTCP has had the
same since d6f8f4e.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jorijn van der Graaf 2026-11-01 01:45:31 +01:00
commit 7dace8bb03
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
2 changed files with 31 additions and 0 deletions

View file

@ -38,6 +38,12 @@ namespace Crafter {
ListenerQUIC(const ListenerQUIC&) = delete;
ListenerQUIC(ListenerQUIC&&) noexcept;
// The UDP port the listener is bound to: the one asked for, or the
// one the system picked when that was 0. Read from msquic once the
// listener has started, so it is valid as soon as the constructor
// returns, and still after Stop(). 0 on a moved-from listener.
std::uint16_t Port() const;
void Stop();
// Block on this thread, dispatch each accepted connection on this