From 85aff44e00e836eda618d4f1cf013bce38b3fd44 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 17 Nov 2024 18:23:17 -0800 Subject: URL u_port should be a number not a string. The idea here is to reduce the dynamic allocations used for URLs, and also the back and forth with parsing begin strings and port numbers. We always resolve to a port number, and this is easier for everyone. The real goal in the long term is to eliminate dynamic allocation of the URL fields altogether, but that requires a little more work. This is a step in the right direction. --- src/core/platform.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/core/platform.h') diff --git a/src/core/platform.h b/src/core/platform.h index 62a321bf..783cc9fc 100644 --- a/src/core/platform.h +++ b/src/core/platform.h @@ -343,7 +343,7 @@ extern int nni_tcp_listener_get( // Symbolic service names will be looked up assuming SOCK_STREAM, so // they may not work with UDP. extern void nni_resolv_ip( - const char *, const char *, int, bool, nng_sockaddr *sa, nni_aio *); + const char *, uint16_t, int, bool, nng_sockaddr *sa, nni_aio *); // nni_parse_ip parses an IP address, without a port. extern int nni_parse_ip(const char *, nng_sockaddr *); @@ -351,6 +351,10 @@ extern int nni_parse_ip(const char *, nng_sockaddr *); // nni_parse_ip_port parses an IP address with an optional port appended. extern int nni_parse_ip_port(const char *, nng_sockaddr *); +// nni_get_port_by_name resolves a name (which may be an ASCII representation +// of a number) to a port number (the value returned is in native byte order.) +extern int nni_get_port_by_name(const char *, uint16_t *); + // // IPC (UNIX Domain Sockets & Named Pipes) Support. // -- cgit v1.2.3-70-g09d2