[Zope-Checkins] 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 matthew at matthewwilkes.co.uk
Fri Mar 18 11:15:01 EDT 2011


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



More information about the Zope-Checkins mailing list