Virtual Method

GioNetworkMonitorcan_reach

since: 2.32

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 recoverable error.

The argument can be NULL.
If the return location is not NULL, then you must initialize it to a NULL GError*.
The argument will left initialized to NULL by the virtual function if there are no errors.
In case of error, the argument will be set to a newly allocated GError; the caller will take ownership of the data, and be responsible for freeing it.

Return value

Type: gboolean

TRUE if connectable is reachable, FALSE if not.