TcpListener.localPort

ushort localPort() @property const @safe nothrow @nogc

Report the effective local port once listening.

Returns

Port number the listener is bound to, or 0 if not listening.