gi-gio-2.0.14: Gio bindings

CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria (garetxe@gmail.com)
Safe HaskellNone
LanguageHaskell2010

GI.Gio.Interfaces.NetworkMonitor

Contents

Description

NetworkMonitor provides an easy-to-use cross-platform API for monitoring network connectivity. On Linux, the implementation is based on the kernel's netlink interface.

Synopsis

Exported types

Methods

canReach

networkMonitorCanReach Source #

Arguments

:: (HasCallStack, MonadIO m, IsNetworkMonitor a, IsSocketConnectable b, IsCancellable c) 
=> a

monitor: a NetworkMonitor

-> b

connectable: a SocketConnectable

-> Maybe c

cancellable: a Cancellable, or Nothing

-> m ()

(Can throw GError)

Attempts to determine whether or not the host pointed to by connectable can be reached, without actually trying to connect to it.

This may return True even when NetworkMonitor:network-available is False, if, for example, monitor can determine that connectable refers to a host on a local network.

If monitor believes that an attempt to connect to connectable will succeed, it will return True. Otherwise, it will return False and set error to an appropriate error (such as IOErrorEnumHostUnreachable).

Note that although this does not attempt to connect to connectable, it may still block for a brief period of time (eg, trying to do multicast DNS on the local network), so if you do not want to block, you should use networkMonitorCanReachAsync.

Since: 2.32

canReachAsync

networkMonitorCanReachAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsNetworkMonitor a, IsSocketConnectable b, IsCancellable c) 
=> a

monitor: a NetworkMonitor

-> b

connectable: a SocketConnectable

-> Maybe c

cancellable: a Cancellable, or Nothing

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied

-> m () 

Asynchronously attempts to determine whether or not the host pointed to by connectable can be reached, without actually trying to connect to it.

For more details, see networkMonitorCanReach.

When the operation is finished, callback will be called. You can then call networkMonitorCanReachFinish to get the result of the operation.

canReachFinish

networkMonitorCanReachFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsNetworkMonitor a, IsAsyncResult b) 
=> a

monitor: a NetworkMonitor

-> b

result: a AsyncResult

-> m ()

(Can throw GError)

Finishes an async network connectivity test. See networkMonitorCanReachAsync.

getConnectivity

networkMonitorGetConnectivity Source #

Arguments

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

monitor: the NetworkMonitor

-> m NetworkConnectivity

Returns: the network connectivity state

Gets a more detailed networking state than networkMonitorGetNetworkAvailable.

If NetworkMonitor:network-available is False, then the connectivity state will be NetworkConnectivityLocal.

If NetworkMonitor:network-available is True, then the connectivity state will be NetworkConnectivityFull (if there is full Internet connectivity), NetworkConnectivityLimited (if the host has a default route, but appears to be unable to actually reach the full Internet), or NetworkConnectivityPortal (if the host is trapped behind a "captive portal" that requires some sort of login or acknowledgement before allowing full Internet access).

Note that in the case of NetworkConnectivityLimited and NetworkConnectivityPortal, it is possible that some sites are reachable but others are not. In this case, applications can attempt to connect to remote servers, but should gracefully fall back to their "offline" behavior if the connection attempt fails.

Since: 2.44

getDefault

networkMonitorGetDefault Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m NetworkMonitor

Returns: a NetworkMonitor

Gets the default NetworkMonitor for the system.

Since: 2.32

getNetworkAvailable

networkMonitorGetNetworkAvailable Source #

Arguments

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

monitor: the NetworkMonitor

-> m Bool

Returns: whether the network is available

Checks if the network is available. "Available" here means that the system has a default route available for at least one of IPv4 or IPv6. It does not necessarily imply that the public Internet is reachable. See NetworkMonitor:network-available for more details.

Since: 2.32

getNetworkMetered

networkMonitorGetNetworkMetered Source #

Arguments

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

monitor: the NetworkMonitor

-> m Bool

Returns: whether the connection is metered

Checks if the network is metered. See NetworkMonitor:network-metered for more details.

Since: 2.46

Properties

connectivity

networkAvailable

networkMetered

Signals

networkChanged