pingNative function

Future<PingResponse> pingNative({
  1. required PingRequire req,
})

Realiza un ping usando el método nativo del sistema operativo

Parámetros:

  • req: Configuración del ping (host, puerto, etc.)

Retorna un Future<PingResponse> con los resultados

Implementation

Future<PingResponse> pingNative({required PingRequire req}) async {
  PingResponse res = PingResponse();
  try {
    Uri uri = Uri.parse(req.host);
    String host = uri.host;
    List<InternetAddress> address = await InternetAddress.lookup(host);
    if (address.isEmpty) {
      res.error = true;
      res.errorRed = true;
    } else {
      res.conexion = await checkHost(address[0], req.port);
      res.ipHost = address[0].address.toString();
    }
    return res;
  } catch (e) {
    return res;
  }
}