Class NetworkAddress
object --+
|
NetworkAddress
NetworkAddress(addr, port=0)
If addr argument is a string it may be either a numeric address or a DNS host
name. First the addr string is tested to see if it can be parsed as a IPv4
Dotted Decimal Notation or IPv6 Hexadecimal Notation, Otherwise the addr string
is passed to PR_GetHostByName to resolve the name. If the name is resolved the
first host entry returned by PR_EnumerateHostEnt is used to initialize the
NetworkAddress. If you need more fine grained control over which address is
selected from the HostEntry then utilize HostEntry.get_network_addresses()
instead.
If the addr argument is an integer it may be one of the following constants:
- PR_IpAddrNull
- Do not set the IP address, only set the port.
NetworkAddress(PR_IpAddrNull, 123) is equivalent to NetworkAddress(port=123)
- PR_IpAddrAny
- Assign logical PR_INADDR_ANY to IP address. This wildcard value is typically
used to establish a socket on which to listen for incoming connection requests.
- PR_IpAddrLoopback
- Assign logical PR_INADDR_LOOPBACK. A client can use this value to connect to
itself without knowing the host's network address.
The optional port argument sets the port number in the NetworkAddress object.
The port number may be modfied later by assigning to the port attribute.
Example:
netaddr = nss.io.NetworkAddress('www.python.org')
print '%s %s' % (netaddr, netaddr.hostname)
netaddr = nss.io.NetworkAddress('82.94.237.218')
print '%s %s' % (netaddr, netaddr.hostname)
Output:
82.94.237.218:0 www.python.org
82.94.237.218:0 dinsdale.python.org
|
__init__(addr,
port=0)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature |
|
|
a new object with type S, a subtype of T
|
|
|
|
|
set_from_string(addr)
Reinitializes the NetworkAddress object given a string. |
|
|
Inherited from object :
__delattr__ ,
__getattribute__ ,
__hash__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__
|
|
family
network address family
|
|
hostentry
HostEntry object representing this NetworkAddress
|
|
hostname
If a hostname was used to construct this NetworkAddress then return that name (e.g.
|
|
port
network address port
|
Inherited from object :
__class__
|
__init__(addr,
port=0)
(Constructor)
|
|
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
- Parameters:
addr (string or integer) - may be an int or a string.
port (integer) - port number
- Overrides:
object.__init__
|
- Returns: a new object with type S, a subtype of T
- Overrides:
object.__new__
|
__str__(x)
(Informal representation operator)
|
|
str(x)
- Overrides:
object.__str__
|
Reinitializes the NetworkAddress object given a string.
Identical to constructing nss.io.NetworkAddress() with a
string value (see constructor for documentation).
- Parameters:
addr (string) - the address string to convert
|
hostname
If a hostname was used to construct this NetworkAddress then return that name (e.g. NetworkAddress(hostname), else return the reverse lookup hostname (equivalent to self.hostentry.hostname)
|