Interface
GioNetworkMonitor
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 fromGInitable
.
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. 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.
since: 2.46
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 |
|
The parent interface. |
|
network_changed |
|
No description available. | |
can_reach |
|
No description available. | |
can_reach_async |
|
No description available. | |
can_reach_finish |
|
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.
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().