isHostReachable method
Ping a single address. See AddressCheckOptions for info on the accepted argument.
Implementation
Future<AddressCheckResult> isHostReachable(
AddressCheckOptions options,
) async {
Socket? sock;
try {
sock = await Socket.connect(
options.address,
options.port,
timeout: options.timeout,
);
sock.destroy();
return AddressCheckResult(options, true);
} catch (e) {
sock?.destroy();
return AddressCheckResult(options, false);
}
}