SVN: Zope/trunk/src/ZServer/datatypes.py The getaddrinfo API provides a superset of the info provided by gethostbyname but isn't ipv4 specific.

Matthew Wilkes <[email protected]>
Newsgroups gmane.comp.web.zope.cvs
Message-ID <20110318151501.1334D941EC__23386.8404444822$1300461310$gmane$org@cvs.zope.org>
Log message for revision 121035:
  The getaddrinfo API provides a superset of the info provided by gethostbyname but isn't ipv4 specific.

Changed:
  U   Zope/trunk/src/ZServer/datatypes.py

-=-
Modified: Zope/trunk/src/ZServer/datatypes.py
===================================================================
--- Zope/trunk/src/ZServer/datatypes.py	2011-03-18 15:12:23 UTC (rev 121034)
+++ Zope/trunk/src/ZServer/datatypes.py	2011-03-18 15:15:00 UTC (rev 121035)
@@ -35,7 +35,9 @@
             ip = socket.gethostbyname(defaulthost)
             self._set_default_host(defaulthost, ip)
         else:
-            self.ip = socket.gethostbyname(self.host)
+            address_info = socket.getaddrinfo(self.host, self.port)
+            ips = [info[4][0] for info in address_info]
+            self.ip = ips[0]
         self.dnsresolver = dnsresolver
         self.module = module
         self.cgienv = env

_______________________________________________
Zope-Checkins maillist  -  [email protected]
https://mail.zope.org/mailman/listinfo/zope-checkins
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.