ping static method
Implementation
static Future<PongData> ping(
{required String host, required int port}) async {
UDP sendSocket = await UDP.bind(Endpoint.any());
sendSocket.send(_buildPingPacket(), await Utils.hostLookup(host, port));
var rawPong =
(sendSocket.asStream().timeout(Duration(seconds: 1), onTimeout: (_) {
throw ServerTimeoutException();
}).first);
return UnconnectedPing.fromBytes((await rawPong)!.data).pong;
}