- 最後登錄
- 2023-4-24
- 在線時間
- 186 小時
- 註冊時間
- 2008-4-1
- 閱讀權限
- 20
- 精華
- 0
- UID
- 3887184
- 帖子
- 372
- 積分
- 21 點
- 潛水值
- 5911 米
| 所有積分大於負-100的壞孩子,將可獲得重新機會成為懲罰生,權限跟幼兒生一樣。 這裡有幾段指令看看是否可行- // args[0] can be an IPaddress or host name.
- public static void Main (string[] args)
- {
- Ping pingSender = new Ping ();
- PingOptions options = new PingOptions ();
- // Use the default Ttl value which is 128,
- // but change the fragmentation behavior.
- options.DontFragment = true;
- // Create a buffer of 32 bytes of data to be transmitted.
- string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
- byte[] buffer = Encoding.ASCII.GetBytes (data);
- int timeout = 120;
- PingReply reply = pingSender.Send (args[0], timeout, buffer, options);
- if (reply.Status == IPStatus.Success)
- {
- Console.WriteLine ("Address: {0}", reply.Address.ToString ());
- Console.WriteLine ("RoundTrip time: {0}", reply.RoundtripTime);
- Console.WriteLine ("Time to live: {0}", reply.Options.Ttl);
- Console.WriteLine ("Don't fragment: {0}", reply.Options.DontFragment);
- Console.WriteLine ("Buffer size: {0}", reply.Buffer.Length);
- }
- }
複製代碼- Microsoft.VisualBasic.Devices.Network net = new Network();
- bool success = net.Ping("填網址");
複製代碼- public bool Ping(host)
- {
- System.Net.NetworkInformation.Ping p = new System.Net.NetworkInformation.Ping();
- if (p.Send(host, 500).Status == System.Net.NetworkInformation.IPStatus.Success) {
- return true;
- } else {
- return false;
- }
- }
複製代碼 ... |
|