发布于 4年前

C# 检查上行链接

public void CheckUplink(string ip)
{
    Ping pingSender = new Ping();
    PingOptions options = new PingOptions();
    options.DontFragment = true;
    string data = "test";
    byte[] buffer = Encoding.ASCII.GetBytes(data);
    //timeout before trigger
    int timeout = 120;
    PingReply reply = pingSender.Send(ip, timeout, buffer, options);
    if (reply.Status == IPStatus.Success)
    {
        //upon success
    }
    else
    {
        //upon failure
    }
}
C#
©2020 edoou.com   京ICP备16001874号-3