Class: Gio::NetworkAddress
- Inherits:
-
Object
- Object
- Gio::NetworkAddress
- Defined in:
- (unknown)
Class Method Summary collapse
-
.parse(host_and_port, default_port) ⇒ Gio::NetworkAddress
Creates a new GSocket::Connectable for connecting to the given hostname and port.
-
.parse_uri(uri, default_port) ⇒ Gio::NetworkAddress
Creates a new GSocket::Connectable for connecting to the given uri.
Instance Method Summary collapse
-
#hostname ⇒ String
Hostname to resolve.
-
#hostname=(hostname) ⇒ String
Hostname to resolve.
-
#initialize(port) ⇒ Gio::NetworkAddress
constructor
Creates a new GSocket::Connectable for connecting to the local host over a loopback connection to the given port.
-
#port ⇒ Integer
Network port.
-
#port=(port) ⇒ Integer
Network port.
-
#scheme ⇒ String
URI scheme.
-
#scheme=(scheme) ⇒ String
URI scheme.
Constructor Details
#initialize(port) ⇒ Gio::NetworkAddress
Creates a new GSocket::Connectable for connecting to the local host over a loopback connection to the given port. This is intended for use in connecting to local services which may be running on IPv4 or IPv6.
The connectable will return IPv4 and IPv6 loopback addresses,
regardless of how the host resolves localhost. By contrast,
g_network_address_new() will often only return an IPv4 address when
resolving localhost, and an IPv6 address for localhost6.
g_network_address_get_hostname() will always return localhost for
a GNetwork::Address created with this constructor.
Class Method Details
.parse(host_and_port, default_port) ⇒ Gio::NetworkAddress
Creates a new GSocket::Connectable for connecting to the given hostname and port. May fail and return nil 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.
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 override if necessary) and default_port is expected to be provided by the application.
(The port component of host_and_port can also be specified as a service name rather than as a numeric port, but this functionality is deprecated, because it depends on the contents of /etc/services, which is generally quite sparse on platforms other than Linux.)
.parse_uri(uri, default_port) ⇒ Gio::NetworkAddress
Creates a new GSocket::Connectable for connecting to the given uri. May fail and return nil in case parsing uri fails.
Using this rather than g_network_address_new() or g_network_address_parse() allows GSocket::Client to determine when to use application-specific proxy protocols.
Instance Method Details
#hostname ⇒ String
Hostname to resolve.
#hostname=(hostname) ⇒ String
Hostname to resolve.
#port ⇒ Integer
Network port.
#port=(port) ⇒ Integer
Network port.
#scheme ⇒ String
URI scheme.
#scheme=(scheme) ⇒ String
URI scheme.