The addrinfo struct member functions addrinfo_get_ip and addrinfo_get_port do not return the correct string representation of ip and port (on Windows 10). When a socket connection is established, this information can be retrieved via the get_name() and get_peer_name() members. For listening sockets, or address structs that are not used in a socket, the addrinfo struct needs to be used.
The data returned is incorrect because:
addrinfo_get_ip() uses sockaddr member sa_data instead of sockaddr_in member sin_addr
addrinfo_get_port() omits to apply correct byte order conversion
The
addrinfo
struct member functionsaddrinfo_get_ip
andaddrinfo_get_port
do not return the correct string representation of ip and port (on Windows 10). When a socket connection is established, this information can be retrieved via theget_name()
andget_peer_name()
members. For listening sockets, or address structs that are not used in a socket, the addrinfo struct needs to be used.The data returned is incorrect because:
addrinfo_get_ip()
usessockaddr
membersa_data
instead ofsockaddr_in
membersin_addr
addrinfo_get_port()
omits to apply correct byte order conversion