Package nss :: Module io :: Class HostEntry
[hide private]
[frames] | no frames]

Class HostEntry

object --+
         |
        HostEntry

HostEntry(addr)

:Parameters:
    addr : string or NetworkAddr object
        May be either a string or a NetworkAddr object.
            - If addr is string it is equivalent to GetHostByName.
            - If addr is a NetworkAddress object it is equivalent to GetHostByAddr.

A HostEntry contains an official name of the host, a set of aliases
for the host name, an address family and a set of network addresses (all
within the single address family).

After successful initialization the HostEntry object will contain
an unordered sequence of `NetworkAddress` objects which may be
accessed via iteration or indexing. It is suggested you try connecting
with the each `NetworkAddress` object in sequential order until
one succeeds.

Example Usage::

    host_entry = io.HostEntry(hostname)
    for net_addr in host_entry:
        net_addr.port = port
        sock = io.Socket(net_addr.family)
        try:
            sock.connect(net_addr, timeout=io.seconds_to_interval(1))
            break
        except Exception, e:
            pass

**WARNING:** HostEntry only supports IPv4 lookups and it's address
list is unordered, HostEntry should be considered *deprecated*. Use
`AddrInfo` instead.

Instance Methods [hide private]
 
__getitem__(x, y)
x[y]
 
__init__(addr)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
 
__len__(x)
len(x)
a new object with type S, a subtype of T

__new__(T, S, ...)
 
__str__(x)
str(x)
 
get_network_address(port=0)
:Parameters: port : integer optional port value specifying the port to associate with the NetworkAddress.
 
get_network_addresses(port=0)
Return a tuple of all possible network address associated with this HostEntry.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Properties [hide private]
  aliases
tuple of aliases for host
  family
address family (e.g.
  hostname
official name of host

Inherited from object: __class__

Method Details [hide private]

__init__(addr)
(Constructor)

 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__

__new__(T, S, ...)

 


Returns:
a new object with type S, a subtype of T

Overrides: object.__new__

__str__(x)
(Informal representation operator)

 
str(x)

Overrides: object.__str__

get_network_address(port=0)

 
:Parameters:
    port : integer
        optional port value specifying the port to associate with the NetworkAddress.

Returns the first network address associated with this HostEntry as a
NetworkAddress object. Equivalent to get_network_addresses()[0]. Note,
may return None if the HostEntry does not have address associated with
it.

get_network_addresses(port=0)

 
Return a tuple of all possible network address associated with this
HostEntry. Each item in the returned tuple is a NetworkAddress object.


Property Details [hide private]

family

address family (e.g. PR_AF_INET, etc.)