InetAddress

class InetAddress(**properties: Any)

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”) for family.

Added in version 2.22.

Parameters:

family – the address family

classmethod new_from_bytes(bytes: Sequence[int], family: SocketFamily) InetAddress

Creates a new InetAddress from the given family and bytes. bytes should be 4 bytes for IPV4 and 16 bytes for IPV6.

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 new InetAddress.

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 for family.

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 family

Added in version 2.22.

get_is_any() bool

Tests whether address is the “any” address for its family.

Added in version 2.22.

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.

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_multicast() bool

Tests whether address is a 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.

get_native_size() int

Gets the size of the native raw binary address for address. This is the size of the data that you get from to_bytes().

Added in version 2.22.

to_string() str

Converts address to string form.

Added in version 2.22.

Properties

class InetAddress
props.bytes: None

The raw address data.

Added in version 2.22.

props.family: SocketFamily

The address family (IPv4 or IPv6).

Added in version 2.22.

props.is_any: bool

Whether this is the “any” address for its family. See get_is_any().

Added in version 2.22.

Whether this is a link-local address. See get_is_link_local().

Added in version 2.22.

props.is_loopback: bool

Whether this is the loopback address for its family. See get_is_loopback().

Added in version 2.22.

props.is_mc_global: bool

Whether this is a global multicast address. See get_is_mc_global().

Added in version 2.22.

Whether this is a link-local multicast address. See get_is_mc_link_local().

Added in version 2.22.

props.is_mc_node_local: bool

Whether this is a node-local multicast address. See get_is_mc_node_local().

Added in version 2.22.

props.is_mc_org_local: bool

Whether this is an organization-local multicast address. See get_is_mc_org_local().

Added in version 2.22.

props.is_mc_site_local: bool

Whether this is a site-local multicast address. See get_is_mc_site_local().

Added in version 2.22.

props.is_multicast: bool

Whether this is a multicast address. See get_is_multicast().

Added in version 2.22.

props.is_site_local: bool

Whether this is a site-local address. See get_is_loopback().

Added in version 2.22.

Virtual Methods

class InetAddress
do_to_string() str

Converts address to string form.

Added in version 2.22.

Fields

class InetAddress
parent_instance
priv