mirror of
https://github.com/netchx/netch.git
synced 2026-03-18 18:13:21 +08:00
Feat ICMPing
This commit is contained in:
@@ -56,6 +56,18 @@ namespace Netch.Utils
|
||||
return timeout;
|
||||
}
|
||||
|
||||
public static int ICMPing(IPAddress ip, int timeout = 1000)
|
||||
{
|
||||
var reply = new Ping().Send(ip, timeout);
|
||||
|
||||
if (reply?.Status == IPStatus.Success)
|
||||
{
|
||||
return Convert.ToInt32(reply.RoundtripTime);
|
||||
}
|
||||
|
||||
return timeout;
|
||||
}
|
||||
|
||||
public static string GetCityCode(string Hostname)
|
||||
{
|
||||
if (Hostname.Contains(":"))
|
||||
|
||||
Reference in New Issue
Block a user