Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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.
The enumeration results of resolved addresses *may* be cached as long as this object is kept alive which may have unexpected results if alive for too long.
See SocketConnectable
for an example of using the connectable
interface.
Synopsis
- newtype NetworkAddress = NetworkAddress (ManagedPtr NetworkAddress)
- class (GObject o, IsDescendantOf NetworkAddress o) => IsNetworkAddress o
- toNetworkAddress :: (MonadIO m, IsNetworkAddress o) => o -> m NetworkAddress
- networkAddressGetHostname :: (HasCallStack, MonadIO m, IsNetworkAddress a) => a -> m Text
- networkAddressGetPort :: (HasCallStack, MonadIO m, IsNetworkAddress a) => a -> m Word16
- networkAddressGetScheme :: (HasCallStack, MonadIO m, IsNetworkAddress a) => a -> m (Maybe Text)
- networkAddressNew :: (HasCallStack, MonadIO m) => Text -> Word16 -> m NetworkAddress
- networkAddressNewLoopback :: (HasCallStack, MonadIO m) => Word16 -> m NetworkAddress
- networkAddressParse :: (HasCallStack, MonadIO m) => Text -> Word16 -> m NetworkAddress
- networkAddressParseUri :: (HasCallStack, MonadIO m) => Text -> Word16 -> m NetworkAddress
- constructNetworkAddressHostname :: (IsNetworkAddress o, MonadIO m) => Text -> m (GValueConstruct o)
- getNetworkAddressHostname :: (MonadIO m, IsNetworkAddress o) => o -> m Text
- constructNetworkAddressPort :: (IsNetworkAddress o, MonadIO m) => Word32 -> m (GValueConstruct o)
- getNetworkAddressPort :: (MonadIO m, IsNetworkAddress o) => o -> m Word32
- constructNetworkAddressScheme :: (IsNetworkAddress o, MonadIO m) => Text -> m (GValueConstruct o)
- getNetworkAddressScheme :: (MonadIO m, IsNetworkAddress o) => o -> m (Maybe Text)
Exported types
newtype NetworkAddress Source #
Memory-managed wrapper type.
Instances
Eq NetworkAddress Source # | |
Defined in GI.Gio.Objects.NetworkAddress (==) :: NetworkAddress -> NetworkAddress -> Bool # (/=) :: NetworkAddress -> NetworkAddress -> Bool # | |
GObject NetworkAddress Source # | |
Defined in GI.Gio.Objects.NetworkAddress | |
ManagedPtrNewtype NetworkAddress Source # | |
Defined in GI.Gio.Objects.NetworkAddress | |
TypedObject NetworkAddress Source # | |
Defined in GI.Gio.Objects.NetworkAddress | |
HasParentTypes NetworkAddress Source # | |
Defined in GI.Gio.Objects.NetworkAddress | |
IsGValue (Maybe NetworkAddress) Source # | Convert |
Defined in GI.Gio.Objects.NetworkAddress gvalueGType_ :: IO GType # gvalueSet_ :: Ptr GValue -> Maybe NetworkAddress -> IO () # gvalueGet_ :: Ptr GValue -> IO (Maybe NetworkAddress) # | |
type ParentTypes NetworkAddress Source # | |
Defined in GI.Gio.Objects.NetworkAddress |
class (GObject o, IsDescendantOf NetworkAddress o) => IsNetworkAddress o Source #
Type class for types which can be safely cast to NetworkAddress
, for instance with toNetworkAddress
.
Instances
(GObject o, IsDescendantOf NetworkAddress o) => IsNetworkAddress o Source # | |
Defined in GI.Gio.Objects.NetworkAddress |
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
Click to display all available methods, including inherited ones
Methods
bindProperty, bindPropertyFull, enumerate, forceFloating, freezeNotify, getv, isFloating, notify, notifyByPspec, proxyEnumerate, ref, refSink, runDispose, stealData, stealQdata, thawNotify, toString, unref, watchClosure.
Getters
getData, getHostname, getPort, getProperty, getQdata, getScheme.
Setters
getHostname
networkAddressGetHostname Source #
:: (HasCallStack, MonadIO m, IsNetworkAddress a) | |
=> a |
|
-> m Text | Returns: |
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 #
:: (HasCallStack, MonadIO m, IsNetworkAddress a) | |
=> a |
|
-> m Word16 | Returns: |
Gets addr
's port number
Since: 2.22
getScheme
networkAddressGetScheme Source #
:: (HasCallStack, MonadIO m, IsNetworkAddress a) | |
=> a |
|
-> m (Maybe Text) | Returns: |
Gets addr
's scheme
Since: 2.26
new
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> Word16 |
|
-> m NetworkAddress | Returns: the new |
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 #
:: (HasCallStack, MonadIO m) | |
=> Word16 |
|
-> m NetworkAddress | Returns: the new |
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
a NetworkAddress
created with this constructor.
Since: 2.44
parse
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> Word16 |
|
-> m NetworkAddress | Returns: the new
|
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 #
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> Word16 |
|
-> m NetworkAddress | Returns: the new
|
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, MonadIO m) => Text -> m (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, MonadIO m) => Word32 -> m (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, MonadIO m) => Text -> m (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 (Maybe Text) Source #
Get the value of the “scheme
” property.
When overloading is enabled, this is equivalent to
get
networkAddress #scheme