Gio.NetworkMonitor::can_reach

function vfunc_can_reach(connectable: Gio.SocketConnectable, cancellable: Gio.Cancellable): Boolean {
}
  

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

a Gio.SocketConnectable

cancellable

a Gio.Cancellable, or null

Returns

true if connectable is reachable, false if not.