isHostReachable method
Implementation
Future<bool> isHostReachable(
InternetAddress host, [
bool debug = true,
]) async {
Socket? sock;
try {
sock = await Socket.connect(
host,
port,
timeout: timeout,
);
sock.destroy();
if (debug) {
if (kDebugMode) {
print('connect Internet Address: $host = true');
}
}
return true;
} catch (e) {
sock?.destroy();
if (kDebugMode) {
print('connect Internet Address: $host = false');
}
return false;
}
}