读书人

判断网络是否连通,该如何解决

发布时间: 2012-05-23 13:44:13 作者: rapoo

判断网络是否连通
1.判断一个IP是否可以连通2
2.判断一个IP的某个端口是否连通

[解决办法]

C# code
1--------Ping pingSender = new Ping();        string strIP =www.baidu.com          //要ping的IP地址     第一种方法本人亲自试验过。可以使用        PingOptions pingOption = new PingOptions();        pingOption.DontFragment = true;        string data = "sendData:goodgoodgoodgoodgoodgood";        byte[] buffer = Encoding.ASCII.GetBytes(data);        int timeout = 120;        PingReply reply = pingSender.Send(strIP, timeout, buffer);        if (reply.Status == IPStatus.Success)        {            Response.Write("能ping通 ");        }        else        {            Response.Write("ping不通");        }2 参考 apsxspy2using System.Net.Sockets;TcpClient iYap = new TcpClient();        try        {            iYap.Connect("127.0.0.1", 8008);            iYap.Close();           Response.Write("<font color=green><b>Open</b></font>");        }        catch        {            Response.Write("<font color=red><b>Close</b></font>");        }你可以下个aspxspy2看看 aspx的木马 

读书人网 >asp.net

热点推荐