Virtual Method

GioNetworkMonitorcan_reach

Declaration

gboolean
can_reach (
  GNetworkMonitor* monitor,
  GSocketConnectable* connectable,
  GCancellable* cancellable,
  GError** error
)

Description

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 GNetworkMonitor: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 G_IO_ERROR_HOST_UNREACHABLE).

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

Available since:2.32

Parameters

connectable

Type: GSocketConnectable

A GSocketConnectable.

The data is owned by the caller of the function.
cancellable

Type: GCancellable

A GCancellable, or NULL.

The argument can be NULL.
The data is owned by the caller of the function.
error

Type: GError **

The return location for a GError*, or NULL.

Return value

Type: gboolean

TRUE if connectable is reachable, FALSE if not.