任何人都可以向我解释此代码的确切作用 [英] can any body explain me what this code do exactly

查看:52
本文介绍了任何人都可以向我解释此代码的确切作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

//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:

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:

WebClient client = new WebClient ();
string reply = client.DownloadString ("www.google.com");

推荐答案

请阅读以下内容,
Please read followings,

  • Ping Class[^]
  • HttpWebRequest Class[^]
  • WebClient Class[^]


这篇关于任何人都可以向我解释此代码的确切作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆