From 925ac884f8bce34ad27fe18e851ebcecfe311356 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Thu, 21 Nov 2024 22:48:32 -0800 Subject: Collect the bound port as part of the URL at bind time. This is a step on cleaning up our logic around NNG_OPT_URL. --- src/sp/transport/tcp/tcp.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/sp/transport/tcp') diff --git a/src/sp/transport/tcp/tcp.c b/src/sp/transport/tcp/tcp.c index 86d0ac07..f619d4d9 100644 --- a/src/sp/transport/tcp/tcp.c +++ b/src/sp/transport/tcp/tcp.c @@ -1023,13 +1023,19 @@ tcptran_ep_set_recvmaxsz(void *arg, const void *v, size_t sz, nni_opt_type t) } static int -tcptran_ep_bind(void *arg) +tcptran_ep_bind(void *arg, nng_url *url) { tcptran_ep *ep = arg; int rv; nni_mtx_lock(&ep->mtx); rv = nng_stream_listener_listen(ep->listener); + if (rv == 0) { + int port; + nng_stream_listener_get_int( + ep->listener, NNG_OPT_TCP_BOUND_PORT, &port); + url->u_port = (uint32_t) port; + } nni_mtx_unlock(&ep->mtx); return (rv); -- cgit v1.2.3-70-g09d2