How to ping a domain name?
I don't think pinging a domain name will tell you anything relevant in a reliable way.
-
The domain name can be registered but not connected to the server. Ping requests will fail even if the domain is registered.
-
The server can be fully operational, but must be configured not to respond to ping requests. Ping requests fail even if the domain is registered and running on the server.
What do you want to do - find out if the domain is registered, is it a valid domain name, or a working website / mail server ...?
For the first two, I would recommend using a service whois
. See for example C # related questions:
a source to share
Using the System.Net.NetworkInformation.Ping class,
using System.Net.NetworkInformation;
Ping sender = new Ping();
PingReply reply = sender.Send ("www.example.com");
if (reply.Status == IPStatus.Success)
{
Console.WriteLine("Ping successful.");
}
This is untested, but that's the general idea.
a source to share