3 ms·
Looks like that function is marked as obsolete, anyone know how long that's been the case? https://www.mankier.com/3/gethostbyname https://www.mankier.com/3/ge
by jap 12y ago
Looks like that function is marked as obsolete, anyone know how long that's been the case?
https://www.mankier.com/3/gethostbyname https://www.mankier.com/3/gethostbyname
"The gethostbyname(), gethostbyaddr(), herror(), and hstrerror() functions are obsolete. Applications should use getaddrinfo(3), getnameinfo(3), and gai_strerror(3) instead."
- martius 12y agoFor a long time: getaddrinfo() and others are specified in susv3[1] (since 2003 I think). However, gethostbyname() and gethostbyaddr() are still very commonly used, and won't be gone soon. 1/ http://refspecs.linuxbase.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/normativerefs.html#STD.SUSV3 http://refspecs.linuxbase.org/LSB_3.1.1/LSB-Core-generic/LSB...
- zrm 12y agoThe main reason gethostbyname is deprecated is that it doesn't support IPv6. The implementation of getaddrinfo uses gethostbyname, so you're using it either way.
- derf_ 12y agoWell, Ulrich Drepper has been trying to get people to stop using it since 2007: https://udrepper.livejournal.com/16116.html https://udrepper.livejournal.com/16116.html And not just because of IPv6.
- AnthonyMouse 12y agoThat seems like a weak argument. It's still going to do the wrong thing when the local machine has a 10.x.x.x address and the local server has a 172.16.x.x address. The right solution is for the local admin to have the local DNS server return only the local address for local clients. getaddrinfo() is also a much more complicated function than gethostbyname(). If you need the extra features, fine. If you're writing new code, fine. But going back and trying to update existing code is just going to introduce new bugs.