Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

309
Vistas
Is it possible pinging with C# like in the CMD?

I'm trying to get IP address of a dns server with the code:

var address = Dns.GetHostAddresses(domain)[0];

Its working on my pc, but when I'm doing it through someone else pc its giving him different result (IPv6 instead of IPv4). I did try to use the method

var ipV4Address = address.MapToIPv4();

but that just returning the wrong IP address

p.s: btw, when using the command ping dns.address.blabla on both computers the result is the same.

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

If the domain have IPv4 and IPv6 addresses, you'll get both. Filter by AddressFamily to InterNetwork only (IPv4) instead of InterNetworkV6 (IPv6)

var ipV4Address = Dns.GetHostAddresses(domain)
                     .First(a => a.AddressFamily == AddressFamily.InterNetwork);
over 4 years ago · Santiago Trujillo Denunciar

0

To answer your specific question in the header: Yes, it is. Here's an outline of how to do that:

        using System.Net.NetworkInformation;
        ...
        private static bool PingWithResponse(int timeout, string iP, out string response)
        {
            bool result = false;

            using (var p = new Ping())
            {
                var r = p.Send(iP, timeout);

                response = $"Ping to {iP} [{r.Address}]";

                if (r.Status == IPStatus.Success)
                {
                    response += $" Successful Response delay = {r.RoundtripTime} ms";
                    result = true;
                }
                else
                {
                    response += $" Failed Status: {r.Status}";
                }
            }

            return result;
        }
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda