Gethostname and IPv6
Microsoft recommends not to use '开发者_如何学Pythongethostname' 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?
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
精彩评论