GInetAddress

GInetAddress — An IPv4/IPv6 address

Synopsis

                    GInetAddress;
GInetAddress *      g_inet_address_new_from_string      (const gchar *string);
GInetAddress *      g_inet_address_new_from_bytes       (const guint8 *bytes,
                                                         GSocketFamily family);
GInetAddress *      g_inet_address_new_any              (GSocketFamily family);
GInetAddress *      g_inet_address_new_loopback         (GSocketFamily family);
gboolean            g_inet_address_equal                (GInetAddress *address,
                                                         GInetAddress *other_address);
const guint8 *      g_inet_address_to_bytes             (GInetAddress *address);
gsize               g_inet_address_get_native_size      (GInetAddress *address);
gchar *             g_inet_address_to_string            (GInetAddress *address);
GSocketFamily       g_inet_address_get_family           (GInetAddress *address);
gboolean            g_inet_address_get_is_any           (GInetAddress *address);
gboolean            g_inet_address_get_is_loopback      (GInetAddress *address);
gboolean            g_inet_address_get_is_link_local    (GInetAddress *address);
gboolean            g_inet_address_get_is_site_local    (GInetAddress *address);
gboolean            g_inet_address_get_is_multicast     (GInetAddress *address);
gboolean            g_inet_address_get_is_mc_link_local (GInetAddress *address);
gboolean            g_inet_address_get_is_mc_node_local (GInetAddress *address);
gboolean            g_inet_address_get_is_mc_site_local (GInetAddress *address);
gboolean            g_inet_address_get_is_mc_org_local  (GInetAddress *address);
gboolean            g_inet_address_get_is_mc_global     (GInetAddress *address);

Object Hierarchy

  GObject
   +----GInetAddress

Properties

  "bytes"                    gpointer              : Read / Write / Construct Only
  "family"                   GSocketFamily         : Read / Write / Construct Only
  "is-any"                   gboolean              : Read
  "is-link-local"            gboolean              : Read
  "is-loopback"              gboolean              : Read
  "is-mc-global"             gboolean              : Read
  "is-mc-link-local"         gboolean              : Read
  "is-mc-node-local"         gboolean              : Read
  "is-mc-org-local"          gboolean              : Read
  "is-mc-site-local"         gboolean              : Read
  "is-multicast"             gboolean              : Read
  "is-site-local"            gboolean              : Read

Description

GInetAddress represents an IPv4 or IPv6 internet address. Use g_resolver_lookup_by_name() or g_resolver_lookup_by_name_async() to look up the GInetAddress for a hostname. Use g_resolver_lookup_by_address() or g_resolver_lookup_by_address_async() to look up the hostname for a GInetAddress.

To actually connect to a remote host, you will need a GInetSocketAddress (which includes a GInetAddress as well as a port number).

Details

GInetAddress

typedef struct _GInetAddress GInetAddress;

An IPv4 or IPv6 internet address.


g_inet_address_new_from_string ()

GInetAddress *      g_inet_address_new_from_string      (const gchar *string);

Parses string as an IP address and creates a new GInetAddress.

string :

a string representation of an IP address

Returns :

a new GInetAddress corresponding to string, or NULL if string could not be parsed.

Since 2.22


g_inet_address_new_from_bytes ()

GInetAddress *      g_inet_address_new_from_bytes       (const guint8 *bytes,
                                                         GSocketFamily family);

Creates a new GInetAddress from the given family and bytes. bytes should be 4 bytes for G_SOCKET_FAMILY_IPV4 and 16 bytes for G_SOCKET_FAMILY_IPV6.

bytes :

raw address data. [array][element-type guint8]

family :

the address family of bytes

Returns :

a new GInetAddress corresponding to family and bytes.

Since 2.22


g_inet_address_new_any ()

GInetAddress *      g_inet_address_new_any              (GSocketFamily family);

Creates a GInetAddress for the "any" address (unassigned/"don't care") for family.

family :

the address family

Returns :

a new GInetAddress corresponding to the "any" address for family.

Since 2.22


g_inet_address_new_loopback ()

GInetAddress *      g_inet_address_new_loopback         (GSocketFamily family);

Creates a GInetAddress for the loopback address for family.

family :

the address family

Returns :

a new GInetAddress corresponding to the loopback address for family.

Since 2.22


g_inet_address_equal ()

gboolean            g_inet_address_equal                (GInetAddress *address,
                                                         GInetAddress *other_address);

Checks if two GInetAddress instances are equal, e.g. the same address.

address :

A GInetAddress.

other_address :

Another GInetAddress.

Returns :

TRUE if address and other_address are equal, FALSE otherwise.

Since 2.30


g_inet_address_to_bytes ()

const guint8 *      g_inet_address_to_bytes             (GInetAddress *address);

Gets the raw binary address data from address.

address :

a GInetAddress

Returns :

a pointer to an internal array of the bytes in address, which should not be modified, stored, or freed. The size of this array can be gotten with g_inet_address_get_native_size().

Since 2.22


g_inet_address_get_native_size ()

gsize               g_inet_address_get_native_size      (GInetAddress *address);

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

address :

a GInetAddress

Returns :

the number of bytes used for the native version of address.

Since 2.22


g_inet_address_to_string ()

gchar *             g_inet_address_to_string            (GInetAddress *address);

Converts address to string form.

address :

a GInetAddress

Returns :

a representation of address as a string, which should be freed after use.

Since 2.22


g_inet_address_get_family ()

GSocketFamily       g_inet_address_get_family           (GInetAddress *address);

Gets address's family

address :

a GInetAddress

Returns :

address's family

Since 2.22


g_inet_address_get_is_any ()

gboolean            g_inet_address_get_is_any           (GInetAddress *address);

Tests whether address is the "any" address for its family.

address :

a GInetAddress

Returns :

TRUE if address is the "any" address for its family.

Since 2.22


g_inet_address_get_is_loopback ()

gboolean            g_inet_address_get_is_loopback      (GInetAddress *address);

Tests whether address is the loopback address for its family.

address :

a GInetAddress

Returns :

TRUE if address is the loopback address for its family.

Since 2.22


g_inet_address_get_is_link_local ()

gboolean            g_inet_address_get_is_link_local    (GInetAddress *address);

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).

address :

a GInetAddress

Returns :

TRUE if address is a link-local address.

Since 2.22


g_inet_address_get_is_site_local ()

gboolean            g_inet_address_get_is_site_local    (GInetAddress *address);

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).

address :

a GInetAddress

Returns :

TRUE if address is a site-local address.

Since 2.22


g_inet_address_get_is_multicast ()

gboolean            g_inet_address_get_is_multicast     (GInetAddress *address);

Tests whether address is a multicast address.

address :

a GInetAddress

Returns :

TRUE if address is a multicast address.

Since 2.22


g_inet_address_get_is_mc_link_local ()

gboolean            g_inet_address_get_is_mc_link_local (GInetAddress *address);

Tests whether address is a link-local multicast address.

address :

a GInetAddress

Returns :

TRUE if address is a link-local multicast address.

Since 2.22


g_inet_address_get_is_mc_node_local ()

gboolean            g_inet_address_get_is_mc_node_local (GInetAddress *address);

Tests whether address is a node-local multicast address.

address :

a GInetAddress

Returns :

TRUE if address is a node-local multicast address.

Since 2.22


g_inet_address_get_is_mc_site_local ()

gboolean            g_inet_address_get_is_mc_site_local (GInetAddress *address);

Tests whether address is a site-local multicast address.

address :

a GInetAddress

Returns :

TRUE if address is a site-local multicast address.

Since 2.22


g_inet_address_get_is_mc_org_local ()

gboolean            g_inet_address_get_is_mc_org_local  (GInetAddress *address);

Tests whether address is an organization-local multicast address.

address :

a GInetAddress

Returns :

TRUE if address is an organization-local multicast address.

Since 2.22


g_inet_address_get_is_mc_global ()

gboolean            g_inet_address_get_is_mc_global     (GInetAddress *address);

Tests whether address is a global multicast address.

address :

a GInetAddress

Returns :

TRUE if address is a global multicast address.

Since 2.22

Property Details

The "bytes" property

  "bytes"                    gpointer              : Read / Write / Construct Only

The raw address data.


The "family" property

  "family"                   GSocketFamily         : Read / Write / Construct Only

The address family (IPv4 or IPv6).

Default value: G_SOCKET_FAMILY_INVALID


The "is-any" property

  "is-any"                   gboolean              : Read

Whether this is the "any" address for its family. See g_inet_address_get_is_any().

Default value: FALSE

Since 2.22


The "is-link-local" property

  "is-link-local"            gboolean              : Read

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

Default value: FALSE

Since 2.22


The "is-loopback" property

  "is-loopback"              gboolean              : Read

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

Default value: FALSE

Since 2.22


The "is-mc-global" property

  "is-mc-global"             gboolean              : Read

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

Default value: FALSE

Since 2.22


The "is-mc-link-local" property

  "is-mc-link-local"         gboolean              : Read

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

Default value: FALSE

Since 2.22


The "is-mc-node-local" property

  "is-mc-node-local"         gboolean              : Read

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

Default value: FALSE

Since 2.22


The "is-mc-org-local" property

  "is-mc-org-local"          gboolean              : Read

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

Default value: FALSE

Since 2.22


The "is-mc-site-local" property

  "is-mc-site-local"         gboolean              : Read

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

Default value: FALSE

Since 2.22


The "is-multicast" property

  "is-multicast"             gboolean              : Read

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

Default value: FALSE

Since 2.22


The "is-site-local" property

  "is-site-local"            gboolean              : Read

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

Default value: FALSE

Since 2.22