GNetworkAddress

GNetworkAddress — a GSocketConnectable for resolving hostnames

Synopsis


#include <gio/gio.h>

                    GNetworkAddress;
GSocketConnectable * g_network_address_new              (const gchar *hostname,
                                                         guint16 port);
const gchar *       g_network_address_get_hostname      (GNetworkAddress *addr);
guint16             g_network_address_get_port          (GNetworkAddress *addr);

Object Hierarchy

  GObject
   +----GNetworkAddress

Implemented Interfaces

GNetworkAddress implements GSocketConnectable.

Properties

  "hostname"                 gchar*                : Read / Write / Construct Only
  "port"                     guint                 : Read / Write / Construct Only

Description

GNetworkAddress provides an easy way to resolve a hostname and then attempt to connect to that host, handling the possibility of multiple IP addresses and multiple address families.

See GSocketConnectable for and example of using the connectable interface.

Details

GNetworkAddress

typedef struct _GNetworkAddress GNetworkAddress;

A GSocketConnectable for resolving a hostname and connecting to that host.


g_network_address_new ()

GSocketConnectable * g_network_address_new              (const gchar *hostname,
                                                         guint16 port);

Creates a new GSocketConnectable for connecting to the given hostname and port.

hostname :

the hostname

port :

the port

Returns :

the new GNetworkAddress

Since 2.22


g_network_address_get_hostname ()

const gchar *       g_network_address_get_hostname      (GNetworkAddress *addr);

Gets addr's hostname. This might be either UTF-8 or ASCII-encoded, depending on what addr was created with.

addr :

a GNetworkAddress

Returns :

addr's hostname

Since 2.22


g_network_address_get_port ()

guint16             g_network_address_get_port          (GNetworkAddress *addr);

Gets addr's port number

addr :

a GNetworkAddress

Returns :

addr's port (which may be 0)

Since 2.22

Property Details

The "hostname" property

  "hostname"                 gchar*                : Read / Write / Construct Only

Hostname to resolve.

Default value: NULL


The "port" property

  "port"                     guint                 : Read / Write / Construct Only

Network port.

Allowed values: <= 65535

Default value: 0