diff options
| author | Garrett D'Amore <garrett@damore.org> | 2025-10-26 10:54:58 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2025-10-27 07:13:40 -0700 |
| commit | be13c2e8845423cec17af429fc4e16a5d9749e47 (patch) | |
| tree | 82614e403a41aac6581a9a223ef9eba5be557222 /src/supplemental/http | |
| parent | 11c53f3d7f747d14fd69ce98c63d629bc821ef68 (diff) | |
| download | nng-be13c2e8845423cec17af429fc4e16a5d9749e47.tar.gz nng-be13c2e8845423cec17af429fc4e16a5d9749e47.tar.bz2 nng-be13c2e8845423cec17af429fc4e16a5d9749e47.zip | |
Replace nng_pipe_get_addr, nng_stream_get_addr, and the NNG_OPT_REMADDR option.
More direct access methods are provided instead.
This results in much lower friction when using, and is a step on the path
to removing NNG_OPT_LOCADDR as well.
We need to figure a solution for NNG_OPT_LOCADDR for dialers; for
listeners there is little use in it either, and it will be removed.
(Dialers will probably get a new NNG_OPT_BIND_IP option.)
Diffstat (limited to 'src/supplemental/http')
| -rw-r--r-- | src/supplemental/http/http_public.c | 8 | ||||
| -rw-r--r-- | src/supplemental/http/http_server_test.c | 6 |
2 files changed, 6 insertions, 8 deletions
diff --git a/src/supplemental/http/http_public.c b/src/supplemental/http/http_public.c index c5ace172..8d91109b 100644 --- a/src/supplemental/http/http_public.c +++ b/src/supplemental/http/http_public.c @@ -565,14 +565,12 @@ nng_http_server_get_tls(nng_http_server *srv, nng_tls_config **cfg) } nng_err -nng_http_server_get_addr(nng_http_server *srv, nng_sockaddr *addr) +nng_http_server_get_port(nng_http_server *srv, int *port) { #ifdef NNG_SUPP_HTTP - size_t size = sizeof(nng_sockaddr); - if (srv == NULL || addr == NULL) - return NNG_EINVAL; + size_t size = sizeof(*port); return (nni_http_server_get( - srv, NNG_OPT_LOCADDR, addr, &size, NNI_TYPE_SOCKADDR)); + srv, NNG_OPT_BOUND_PORT, port, &size, NNI_TYPE_INT32)); #else NNI_ARG_UNUSED(srv); NNI_ARG_UNUSED(addr); diff --git a/src/supplemental/http/http_server_test.c b/src/supplemental/http/http_server_test.c index d299cb97..19449b9c 100644 --- a/src/supplemental/http/http_server_test.c +++ b/src/supplemental/http/http_server_test.c @@ -190,7 +190,7 @@ httpaddrcheck(nng_http *conn, void *arg, nng_aio *aio) static void server_setup(struct server_test *st, nng_http_handler *h) { - nng_sockaddr sa; + int port; memset(st, 0, sizeof(*st)); NUTS_PASS(nng_url_parse(&st->url, "http://127.0.0.1:0")); NUTS_PASS(nng_aio_alloc(&st->aio, NULL, NULL)); @@ -200,8 +200,8 @@ server_setup(struct server_test *st, nng_http_handler *h) NUTS_PASS(nng_http_server_add_handler(st->s, h)); } NUTS_PASS(nng_http_server_start(st->s)); - NUTS_PASS(nng_http_server_get_addr(st->s, &sa)); - nng_url_resolve_port(st->url, nng_sockaddr_port(&sa)); + NUTS_PASS(nng_http_server_get_port(st->s, &port)); + nng_url_resolve_port(st->url, (uint32_t) port); nng_url_sprintf(st->urlstr, sizeof(st->urlstr), st->url); NUTS_PASS(nng_http_client_alloc(&st->cli, st->url)); |
