Gio.NetworkMonitor.prototype.can_reach
function can_reach(connectable: Gio.SocketConnectable, cancellable: Gio.Cancellable): Boolean { // Gjs wrapper for 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.
This may return true even when Gio.NetworkMonitor-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 Gio.IOErrorEnum.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 Gio.NetworkMonitor.prototype.can_reach_async.
Since 2.32
- connectable
- cancellable
a Gio.Cancellable, or null
- Returns
true if connectable is reachable, false if not.