At Saturday 23/12/2006 04:21, [EMAIL PROTECTED] wrote:
I noticed the following lines from the connect() method of the
HTTPConnection class within httplib:
for res in socket.getaddrinfo(self.host, self.port, 0,
socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res
This led me to the docs that describe the socket.getaddrinfo() method:
http://www.python.org/doc/2.4.1/lib/module-socket.html
Which leads me to these questions:
1) Is it correct to infer from the "Resolves the host/port argument,
into a sequence of 5-tuples that contain all the necessary argument for
the sockets manipulation" description in the docs (in particular the
reference to 'sequence of 5-tuples') that a single host/port
combination may be associated with multiple sets of address
information?
Yes. By example, multiple addresses for the same service are used for
load balancing. Or an IPv4 address plus an IPv6 address.
2) In the very limited applications on which I've used
socket.getaddrinfo(), each a host/port combination that my application
passes to socket.getaddrinfo() has always returned a 1-entry list where
the list is a 5-tuple, in other words, each host/port combination has
always been associated with one set of address information. Can
someone point me to a host/port combination that, when passed to
socket.getaddrinfo() will result in socket.getaddrinfo() returning a
list of > 1 entry, where each entry is a 5-tuple?
Try to relax your restrictions.
import socket
host = 'www.microsoft.com'
port = 'ftp'
for res in socket.getaddrinfo(host, port):
print res
Got 8 results:
(2, 1, 0, '', ('207.46.198.30', 21))
(2, 1, 0, '', ('207.46.198.60', 21))
(2, 1, 0, '', ('207.46.199.30', 21))
(2, 1, 0, '', ('207.46.225.60', 21))
(2, 1, 0, '', ('207.46.19.30', 21))
(2, 1, 0, '', ('207.46.19.60', 21))
(2, 1, 0, '', ('207.46.20.30', 21))
(2, 1, 0, '', ('207.46.20.60', 21))
--
Gabriel Genellina
Softlab SRL
__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas
--
http://mail.python.org/mailman/listinfo/python-list