[Dotty/Lneato/Lefty] io.c uses obsoleted function gethostbyname
Ported Issue from Mantis Original ID: 2387 Attachments may only be available from the Mantis Tracker Reported By: Jaroslav Skarvada
SEVERITY: MINOR Submitted: 2013-10-30 17:24:01
From the manual page:
The gethostbyname_() and gethostbyaddr_() functions are obsolete. Applications should use getaddrinfo(3) and getnameinfo(3) instead.
AFAIK, among the others, the getaddrinfo implements the RFC 3484, so it may be better for IPv6 or dual stack machines.
STEPS TO REPRODUCE
Check the code.
The code from the attached patch tries to connect to the first IP the OS things is the most suitable for the connection. In practice on dual stack machines this mostly means: if the hostname resolves to both IPv4 and IPv6 IPs and IPv6 is up, the IPv6 IP is taken.
Such approach can fail if there is e.g. internal IPv6 connectivity but no external IPv6 connectivity and the AAAA records of external hostnames are still resolvable. For such cases we could retry all the returned IPs one by one in a simple loop. This would be more robust approach, but it could cause big timeouts if the network connection suddenly drops after the getaddrinfo call.