Reputation: 1478
Microsoft recommends not to use 'gethostname' on IPv6 and instead use 'getaddrinfo' or 'getnameinfo'.
http://msdn.microsoft.com/en-us/library/ms899604.aspx
But 'gethostname' doesn't seem to have any problem working on IPv6. Does anyone know any reason why 'gethostname' is not recommended on IPv6?
Upvotes: 2
Views: 2173
Reputation: 12866
The main different is the maximum host name length, gethostname()
allows 255+1 characters, getnameinfo()
supports the full DNS length of 1024+1. If you are using technologies like puny code host names this becomes more pertinent. Other differences are that you are not guaranteed a FQDN when using gethostname()
.
http://en.wikipedia.org/wiki/Internationalized_domain_name
Upvotes: 3