Create  Edit  FrontPage  Index  Search  Changes  History  RSS  Login


class GLib::NetworkAddress

GLib::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.

See GLib::SocketConnectable for and example of using the connectable interface.

Class Methods, port)
Creates a new GLib::SocketConnectable for connecting to the given hostname and port.
GLib::NetworkAddress.parse(host_and_port, default_port)

Creates a new GLib::NetworkAddress for connecting to the given hostname and port. May fail and raise an error, in case parsing host_and_port fails.

Host_and_port may be in any of a number of recognised formats: an IPv6 address, an IPv4 address, or a domain name (in which case a DNS lookup is performed). Quoting with [] is supported for all address types. A port override may be specified in the usual way with a colon. Ports may be given as decimal numbers or symbolic names (in which case an /etc/services lookup is performed).

If no port is specified in host_and_port then default_port will be used as the port number to connect to.

In general, host_and_port is expected to be provided by the user (allowing them to give the hostname, and a port overide if necessary) and default_port is expected to be provided by the application.

Since 2.22

  • host_and_port: The hostname and optionally a port
  • default_port: The default port if not in host_and_port
  • Returns: The new GLib::NetworkAddress

Instance Methods

See GLib::SocketConnectable#each.
See GLib::SocketConnectable#enumerate.
Gets the hostname to resolve.
  • Returns: The Hostname to resolve
Gets the network port.
  • Returns: The Network port
Gets the URI Scheme.
  • Returns: The URI Scheme