# Gio::NetworkAddress Class Reference
[Portable Network I/O Functionality]

A SocketConnectable for resolving hostnames. More...

`#include <giomm/networkaddress.h>`

Inheritance diagram for Gio::NetworkAddress:
[legend]

List of all members.

## Public Member Functions

virtual | ~NetworkAddress ()
GNetworkAddress* | gobj ()
| Provides access to the underlying C GObject.
const GNetworkAddress* | gobj () const
| Provides access to the underlying C GObject.
GNetworkAddress* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
std::string | get_hostname () const
| Gets addr's hostname.
guint16 | get_port () const
| Gets addr's port number.
std::string | get_scheme () const
Glib::PropertyProxy_ReadOnly < std::string > | property_hostname () const
| Hostname to resolve.
Glib::PropertyProxy_ReadOnly < guint > | property_port () const
| Network port.
Glib::PropertyProxy_ReadOnly < std::string > | property_scheme () const
| URI Scheme.

## Static Public Member Functions

static Glib::RefPtr < NetworkAddress > | create (const std::string& hostname, guint16 port)
static Glib::RefPtr < NetworkAddress > | parse (const std::string& host_and_port, guint16 default_port)

## Related Functions

(Note that these are not member functions.)
Glib::RefPtr< Gio::NetworkAddress > | wrap (GNetworkAddress* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

A SocketConnectable for resolving hostnames.

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

Since glibmm 2.24:

## Constructor & Destructor Documentation

virtual Gio::NetworkAddress::~NetworkAddress | ( | ) | `[virtual]`

## Member Function Documentation

static Glib::RefPtr<NetworkAddress> Gio::NetworkAddress::create | ( | const std::string & | hostname,
|  | guint16 | port
| ) |  | `[static]`

std::string Gio::NetworkAddress::get_hostname | ( | ) | const

Gets addr's hostname.

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

Since glibmm 2.22:

Returns:
  addr's hostname.

guint16 Gio::NetworkAddress::get_port | ( | ) | const

Gets addr's port number.

Since glibmm 2.22:

Returns:
  addr's port (which may be 0).

std::string Gio::NetworkAddress::get_scheme | ( | ) | const

const GNetworkAddress* Gio::NetworkAddress::gobj | ( | ) | const`[inline]`

Provides access to the underlying C GObject.

Reimplemented from Gio::SocketConnectable.

GNetworkAddress* Gio::NetworkAddress::gobj | ( | ) | `[inline]`

Provides access to the underlying C GObject.

Reimplemented from Gio::SocketConnectable.

GNetworkAddress* Gio::NetworkAddress::gobj_copy | ( | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

static Glib::RefPtr<NetworkAddress> Gio::NetworkAddress::parse | ( | const std::string & | host_and_port,
|  | guint16 | default_port
| ) |  | `[static]`

Glib::PropertyProxy_ReadOnly<std::string> Gio::NetworkAddress::property_hostname | ( | ) | const

Hostname to resolve.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<guint> Gio::NetworkAddress::property_port | ( | ) | const

Network port.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly<std::string> Gio::NetworkAddress::property_scheme | ( | ) | const

URI Scheme.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

## Friends And Related Function Documentation

Glib::RefPtr< Gio::NetworkAddress > wrap | ( | GNetworkAddress * | object,
|  | bool | take_copy = `false`
| ) |  | `[related]`

A Glib::wrap() method for this object.

Parameters:

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns:
  A C++ instance that wraps this C instance.