gi-gio-2.0.24: Gio bindings

CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria (inaki@blueleaf.cc)
Safe HaskellNone
LanguageHaskell2010

GI.Gio.Objects.NetworkAddress

Contents

Description

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 SocketConnectable for an example of using the connectable interface.

Synopsis

Exported types

newtype NetworkAddress Source #

Memory-managed wrapper type.

class (GObject o, IsDescendantOf NetworkAddress o) => IsNetworkAddress o Source #

Type class for types which can be safely cast to NetworkAddress, for instance with toNetworkAddress.

toNetworkAddress :: (MonadIO m, IsNetworkAddress o) => o -> m NetworkAddress Source #

Cast to NetworkAddress, for types for which this is known to be safe. For general casts, use castTo.

Methods

getHostname

networkAddressGetHostname Source #

Arguments

:: (HasCallStack, MonadIO m, IsNetworkAddress a) 
=> a

addr: a NetworkAddress

-> m Text

Returns: addr's hostname

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

Since: 2.22

getPort

networkAddressGetPort Source #

Arguments

:: (HasCallStack, MonadIO m, IsNetworkAddress a) 
=> a

addr: a NetworkAddress

-> m Word16

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

Gets addr's port number

Since: 2.22

getScheme

networkAddressGetScheme Source #

Arguments

:: (HasCallStack, MonadIO m, IsNetworkAddress a) 
=> a

addr: a NetworkAddress

-> m Text

Returns: addr's scheme (Nothing if not built from URI)

Gets addr's scheme

Since: 2.26

new

networkAddressNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

hostname: the hostname

-> Word16

port: the port

-> m NetworkAddress

Returns: the new NetworkAddress

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

Note that depending on the configuration of the machine, a hostname of localhost may refer to the IPv4 loopback address only, or to both IPv4 and IPv6; use networkAddressNewLoopback to create a NetworkAddress that is guaranteed to resolve to both addresses.

Since: 2.22

newLoopback

networkAddressNewLoopback Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Word16

port: the port

-> m NetworkAddress

Returns: the new NetworkAddress

Creates a new SocketConnectable 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, networkAddressNew will often only return an IPv4 address when resolving localhost, and an IPv6 address for localhost6.

networkAddressGetHostname will always return localhost for GNetworkAddresses created with this constructor.

Since: 2.44

parse

networkAddressParse Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

hostAndPort: the hostname and optionally a port

-> Word16

defaultPort: the default port if not in hostAndPort

-> m NetworkAddress

Returns: the new NetworkAddress, or Nothing on error (Can throw GError)

Creates a new SocketConnectable for connecting to the given hostname and port. May fail and return Nothing in case parsing hostAndPort fails.

hostAndPort 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 hostAndPort then defaultPort will be used as the port number to connect to.

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

(The port component of hostAndPort 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.)

Since: 2.22

parseUri

networkAddressParseUri Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

uri: the hostname and optionally a port

-> Word16

defaultPort: The default port if none is found in the URI

-> m NetworkAddress

Returns: the new NetworkAddress, or Nothing on error (Can throw GError)

Creates a new SocketConnectable for connecting to the given uri. May fail and return Nothing in case parsing uri fails.

Using this rather than networkAddressNew or networkAddressParse allows SocketClient to determine when to use application-specific proxy protocols.

Since: 2.26

Properties

hostname

No description available in the introspection data.

constructNetworkAddressHostname :: IsNetworkAddress o => Text -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “hostname” property. This is rarely needed directly, but it is used by new.

getNetworkAddressHostname :: (MonadIO m, IsNetworkAddress o) => o -> m Text Source #

Get the value of the “hostname” property. When overloading is enabled, this is equivalent to

get networkAddress #hostname

port

No description available in the introspection data.

constructNetworkAddressPort :: IsNetworkAddress o => Word32 -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “port” property. This is rarely needed directly, but it is used by new.

getNetworkAddressPort :: (MonadIO m, IsNetworkAddress o) => o -> m Word32 Source #

Get the value of the “port” property. When overloading is enabled, this is equivalent to

get networkAddress #port

scheme

No description available in the introspection data.

constructNetworkAddressScheme :: IsNetworkAddress o => Text -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “scheme” property. This is rarely needed directly, but it is used by new.

getNetworkAddressScheme :: (MonadIO m, IsNetworkAddress o) => o -> m Text Source #

Get the value of the “scheme” property. When overloading is enabled, this is equivalent to

get networkAddress #scheme