can_reach


Description:

public abstract bool can_reach (SocketConnectable connectable, Cancellable? cancellable = null) throws Error

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 network_available is false, if, for example, this can determine that connectable refers to a host on a local network.

If this believes that an attempt to connect to connectable will succeed, it will return true. Otherwise, it will return false and set throws 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 can_reach_async.

Parameters:

this

a NetworkMonitor

connectable

a SocketConnectable

cancellable

a Cancellable, or null

Returns:

true if connectable is reachable, false if not.