Click here to Skip to main content
15,923,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
//you could use either ip or hostname
var ip = "127.0.0.0";
var hostname = "hostname.com";

  Ping pinger = new Ping ();

            byte[] buffer = Encoding.ASCII.GetBytes ("test123");
            int timeout = 60;
            PingReply reply = pinger.Send (ip, timeout, buffer);
            if (reply.Status == IPStatus.Success)
            {
//hooray
            }else{
//nope
}

head request:
C#
try{
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
request.Method = "HEAD";
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
WebHeaderCollection headers = response.Headers;
//hooray

}catch(Exception ex){
//nope
}

download default page:
C#
WebClient client = new WebClient ();
string reply = client.DownloadString ("www.google.com");
Posted
Updated 18-Apr-12 2:35am
v2
Comments
bbirajdar 18-Apr-12 8:53am    
If the person who has written it does not know what the code does , then how do you expect somebody else to guess it?

1 solution

Please read followings,

Hope it helps :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900