using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Net.NetworkInformation;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace LB_SmartVisionCommon
|
{
|
public class NetworkTester
|
{
|
public static async Task<bool> TestConnectionAsync(string host, int timeout = 3000)
|
{
|
try
|
{
|
using (var ping = new Ping())
|
{
|
var reply = await ping.SendPingAsync(host, timeout);
|
AsyncLogHelper.Warn("相机IP:" + host + "通讯正常!");
|
return reply.Status == IPStatus.Success;
|
}
|
}
|
catch
|
{
|
AsyncLogHelper.Warn("相机IP:" + host + "通讯异常!");
|
return false;
|
}
|
}
|
|
public static bool TestConnection(string host, int timeout = 3000)
|
{
|
try
|
{
|
using (var ping = new Ping())
|
{
|
var reply = ping.Send(host, timeout);
|
return reply.Status == IPStatus.Success;
|
}
|
}
|
catch
|
{
|
return false;
|
}
|
}
|
}
|
}
|