diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-11-21 22:48:32 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-11-21 22:48:32 -0800 |
| commit | 925ac884f8bce34ad27fe18e851ebcecfe311356 (patch) | |
| tree | f5ef6ed18876688a695af49a89df12114505f65f /src/sp/transport/tcp/tcp.c | |
| parent | 7ea8abadec355eb7ea9f71fc2e2bdd73c1c77c62 (diff) | |
| download | nng-925ac884f8bce34ad27fe18e851ebcecfe311356.tar.gz nng-925ac884f8bce34ad27fe18e851ebcecfe311356.tar.bz2 nng-925ac884f8bce34ad27fe18e851ebcecfe311356.zip | |
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.
Diffstat (limited to 'src/sp/transport/tcp/tcp.c')
| -rw-r--r-- | src/sp/transport/tcp/tcp.c | 8 |
1 files changed, 7 insertions, 1 deletions
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); |
