Interface

GioNetworkMonitor

Description [src]

interface Gio.NetworkMonitor : Gio.Initable

GNetworkMonitor provides an easy-to-use cross-platform API for monitoring network connectivity. On Linux, the available implementations are based on the kernel’s netlink interface and on NetworkManager.

There is also an implementation for use inside Flatpak sandboxes.

Available since:2.32

Prerequisite

In order to implement NetworkMonitor, your type must inherit from GInitable.

Functions

g_network_monitor_get_default

Gets the default GNetworkMonitor for the system.

Instance methods

g_network_monitor_can_reach

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

Available since: 2.32

g_network_monitor_can_reach_async

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

g_network_monitor_can_reach_finish

Finishes an async network connectivity test. See g_network_monitor_can_reach_async().

g_network_monitor_get_connectivity

Gets a more detailed networking state than g_network_monitor_get_network_available().

Available since: 2.44

g_network_monitor_get_network_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 GNetworkMonitor:network-available for more details.

Available since: 2.32

g_network_monitor_get_network_metered

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

Available since: 2.46

Properties

Gio.NetworkMonitor:connectivity

More detailed information about the host’s network connectivity. See g_network_monitor_get_connectivity() and GNetworkConnectivity for more details.

Available since: 2.44

Gio.NetworkMonitor:network-available

Whether the network is considered available. That is, whether the system has a default route for at least one of IPv4 or IPv6.

Available since: 2.32

Gio.NetworkMonitor:network-metered

Whether the network is considered metered. That is, whether the system has traffic flowing through the default connection that is subject to limitations set by service providers. For example, traffic might be billed by the amount of data transmitted, or there might be a quota on the amount of traffic per month. This is typical with tethered connections (3G and 4G) and in such situations, bandwidth intensive applications may wish to avoid network activity where possible if it will cost the user money or use up their limited quota.

Available since: 2.46

Signals

Gio.NetworkMonitor::network-changed

Emitted when the network configuration changes.

Available since: 2.32

Interface structure

struct GioNetworkMonitorInterface {
  GTypeInterface g_iface;
  void (* network_changed) (
    GNetworkMonitor* monitor,
    gboolean network_available
  );
  gboolean (* can_reach) (
    GNetworkMonitor* monitor,
    GSocketConnectable* connectable,
    GCancellable* cancellable,
    GError** error
  );
  void (* can_reach_async) (
    GNetworkMonitor* monitor,
    GSocketConnectable* connectable,
    GCancellable* cancellable,
    GAsyncReadyCallback callback,
    gpointer user_data
  );
  gboolean (* can_reach_finish) (
    GNetworkMonitor* monitor,
    GAsyncResult* result,
    GError** error
  );
  
}
Interface members
g_iface
GTypeInterface
 

The parent interface.

network_changed
void (* network_changed) (
    GNetworkMonitor* monitor,
    gboolean network_available
  )
 No description available.
can_reach
gboolean (* can_reach) (
    GNetworkMonitor* monitor,
    GSocketConnectable* connectable,
    GCancellable* cancellable,
    GError** error
  )
 No description available.
can_reach_async
void (* can_reach_async) (
    GNetworkMonitor* monitor,
    GSocketConnectable* connectable,
    GCancellable* cancellable,
    GAsyncReadyCallback callback,
    gpointer user_data
  )
 No description available.
can_reach_finish
gboolean (* can_reach_finish) (
    GNetworkMonitor* monitor,
    GAsyncResult* result,
    GError** error
  )
 No description available.

Virtual methods

Gio.NetworkMonitor.can_reach

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

Gio.NetworkMonitor.can_reach_async

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

Gio.NetworkMonitor.can_reach_finish

Finishes an async network connectivity test. See g_network_monitor_can_reach_async().

Gio.NetworkMonitor.network_changed
No description available.