任何人都可以向我解释此代码的确切作用

任何人都可以向我解释此代码的确切作用

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

问题描述

//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");

推荐答案


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

08-23 22:18