### Interface

# Gio NetworkMonitor

since: 2.32

#### Description

    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.

since: 2.32

#### 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.

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().

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.

since: 2.32

###### g_network_monitor_get_network_metered

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

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.

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.

since: 2.32

###### Gio.NetworkMonitor:network-metered

Whether the network is considered metered.

since: 2.46

#### Signals

###### Gio.NetworkMonitor::network-changed

Emitted when the network configuration changes.

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
      );

    }

The virtual function table for `GNetworkMonitor`.

###### Interface members

`g_iface` |
    GTypeInterface
| The parent interface.
`network_changed` |
    void (* network_changed) (
        GNetworkMonitor* monitor,
        gboolean network_available
      )
| The virtual function pointer for the GNetworkMonitor::network-changed signal.
`can_reach` |
    gboolean (* can_reach) (
        GNetworkMonitor* monitor,
        GSocketConnectable* connectable,
        GCancellable* cancellable,
        GError** error
      )
| The virtual function pointer for g_network_monitor_can_reach().
`can_reach_async` |
    void (* can_reach_async) (
        GNetworkMonitor* monitor,
        GSocketConnectable* connectable,
        GCancellable* cancellable,
        GAsyncReadyCallback callback,
        gpointer user_data
      )
| The virtual function pointer for g_network_monitor_can_reach_async().
`can_reach_finish` |
    gboolean (* can_reach_finish) (
        GNetworkMonitor* monitor,
        GAsyncResult* result,
        GError** error
      )
| The virtual function pointer for g_network_monitor_can_reach_finish().

#### 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.

since: 2.32

###### 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

The virtual function pointer for the GNetworkMonitor::network-changed signal.