InetAddress#
Superclasses: Object
GInetAddress
represents an IPv4 or IPv6 internet address. Use
lookup_by_name
or
lookup_by_name_async
to look up the GInetAddress
for
a hostname. Use lookup_by_address
or
lookup_by_address_async
to look up the hostname for a
GInetAddress
.
To actually connect to a remote host, you will need a
InetSocketAddress
(which includes a GInetAddress
as well as a
port number).
Constructors#
- class InetAddress
- classmethod new_any(family: SocketFamily) InetAddress #
Creates a
InetAddress
for the “any” address (unassigned/”don’t care”) forfamily
.Added in version 2.22.
- Parameters:
family – the address family
- classmethod new_from_bytes(bytes: list[int], family: SocketFamily) InetAddress #
Creates a new
InetAddress
from the givenfamily
andbytes
.bytes
should be 4 bytes forIPV4
and 16 bytes forIPV6
.Added in version 2.22.
- Parameters:
bytes – raw address data
family – the address family of
bytes
- classmethod new_from_string(string: str) InetAddress | None #
Parses
string
as an IP address and creates a newInetAddress
.Added in version 2.22.
- Parameters:
string – a string representation of an IP address
- classmethod new_loopback(family: SocketFamily) InetAddress #
Creates a
InetAddress
for the loopback address forfamily
.Added in version 2.22.
- Parameters:
family – the address family
Methods#
- class InetAddress
-
- equal(other_address: InetAddress) bool #
Checks if two
InetAddress
instances are equal, e.g. the same address.Added in version 2.30.
- Parameters:
other_address – Another
InetAddress
.
- get_family() SocketFamily #
Gets
address
's familyAdded in version 2.22.
- get_is_any() bool #
Tests whether
address
is the “any” address for its family.Added in version 2.22.
- get_is_link_local() bool #
Tests whether
address
is a link-local address (that is, if it identifies a host on a local network that is not connected to the Internet).Added in version 2.22.
- get_is_loopback() bool #
Tests whether
address
is the loopback address for its family.Added in version 2.22.
- get_is_mc_global() bool #
Tests whether
address
is a global multicast address.Added in version 2.22.
- get_is_mc_link_local() bool #
Tests whether
address
is a link-local multicast address.Added in version 2.22.
- get_is_mc_node_local() bool #
Tests whether
address
is a node-local multicast address.Added in version 2.22.
- get_is_mc_org_local() bool #
Tests whether
address
is an organization-local multicast address.Added in version 2.22.
- get_is_mc_site_local() bool #
Tests whether
address
is a site-local multicast address.Added in version 2.22.
- get_is_site_local() bool #
Tests whether
address
is a site-local address such as 10.0.0.1 (that is, the address identifies a host on a local network that can not be reached directly from the Internet, but which may have outgoing Internet connectivity via a NAT or firewall).Added in version 2.22.
Properties#
- class InetAddress
-
- props.family: SocketFamily#
The type of the None singleton.
Added in version 2.22.