标签:状态 send catch spi class googl style ndpi span
网络连接判断,使用ping测试获取:
1 private static async Task<bool> IsPingSuccess() 2 { 3 try 4 { 5 using (Ping myPing = new Ping()) 6 { 7 var result = await myPing.SendPingAsync("google.com", 3000 /*3 secs timeout*/, new byte[32], new PingOptions(64, true)); 8 return result.Status == IPStatus.Success; 9 } 10 } 11 catch 12 { 13 // ignored 14 } 15 return false; 16 }
ping获取网络状态的耗时,一般在几十ms,延时性偏高
标签:状态 send catch spi class googl style ndpi span
原文地址:https://www.cnblogs.com/kybs0/p/12971890.html