You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is different from the behavior of the tcp transport, which allows binding to localhost and many other types of address names.
I believe the issue stems from zmq::udp_address_t::resolve(const char *name_, bool bind_) in src/udp_address.cpp. This function expects the endpoint name to be a ":" separated address and port. After splitting the name argument into addr_str and port_str, addr_str is translated to a in_addr_t struct using inet_addr(). The manpage for inet_addr, man inet_addr says:
The inet_addr() function converts the Internet host address cp from IPv4 numbers-and-dots notation into binary data in network byte order. If the input is invalid, INADDR_NONE (usually -1) is returned. Use of this function is problematic because -1 is a valid address (255.255.255.255). Avoid its use in favor of inet_aton(), inet_pton(3), or getaddrinfo(3) which provide a cleaner way to indicate error return.
Were getaddrinfo used instead of inet_addr (as it is in the zmq::tcp_address_t::resolve_interface (const char *interface_, bool ipv6_, bool is_src_) function from src/tcp_address.cpp) a name like "localhost" or even an IPv6 address would work. From the getaddrinfo manpage:
int getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res); node specifies either a numerical network address (for IPv4, numbers-and-dots notation as supported by inet_aton(3); for IPv6, hexadecimal string format as supported by inet_pton(3)), or a network hostname, whose network addresses are looked up and resolved. service sets the port in each returned address structure. If this argument is a service name (see services(5)), it is translated to the corresponding port number. This argument can also be specified as a decimal number, which is simply converted to binary.
Is there a reason the udp resolve function cannot be switched from using inet_addr() to getaddrinfo() so as to support name lookups and possibly also IPv6?
Environment
libzmq version (commit hash if unreleased): 4.2.3
OS: CentOS 6.9
The text was updated successfully, but these errors were encountered:
Issue description
The udp transport requires addresses passed into it be in IPv4 dotted notation. Take this sample program:
this is ok:
but this is not ok
This is different from the behavior of the tcp transport, which allows binding to localhost and many other types of address names.
I believe the issue stems from
zmq::udp_address_t::resolve(const char *name_, bool bind_)
in src/udp_address.cpp. This function expects the endpoint name to be a ":" separated address and port. After splitting the name argument intoaddr_str
andport_str
,addr_str
is translated to ain_addr_t
struct usinginet_addr()
. The manpage for inet_addr,man inet_addr
says:Were
getaddrinfo
used instead ofinet_addr
(as it is in thezmq::tcp_address_t::resolve_interface (const char *interface_, bool ipv6_, bool is_src_)
function from src/tcp_address.cpp) a name like "localhost" or even an IPv6 address would work. From thegetaddrinfo
manpage:Is there a reason the udp resolve function cannot be switched from using
inet_addr()
togetaddrinfo()
so as to support name lookups and possibly also IPv6?Environment
The text was updated successfully, but these errors were encountered: