网站建设资讯

NEWS

网站建设资讯

检测80端口是否开启

public static  void port_check(string ip)

安福网站制作公司哪家好,找成都创新互联!从网页设计、网站建设、微信开发、APP开发、成都响应式网站建设等网站项目制作,到程序开发,运营维护。成都创新互联从2013年开始到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选成都创新互联

        {

            bool tcpListen = false;

            bool udpListen = false;//设定端口状态标识位

            string ip_str = ip;

            System.Net.IPAddress myIpAddress = IPAddress.Parse(ip_str);

            System.Net.IPEndPoint myIpEndPoint = new IPEndPoint(myIpAddress, 80);

            try

            {

                System.Net.Sockets.TcpClient tcpClient = new TcpClient();

                tcpClient.Connect(myIpEndPoint);//对远程计算机的指定端口提出TCP连接请求

                tcpListen = true;

            }

            catch { }

            try

            {

                System.Net.Sockets.UdpClient udpClient = new UdpClient();

                udpClient.Connect(myIpEndPoint);//对远程计算机的指定端口提出UDP连接请求

                udpListen = true;

            }

            catch { }

            if (tcpListen == false && udpListen == false)

            {

                Console.WriteLine("80端口关闭!", "提示");

            }

            else

            {

                Console.WriteLine("80端口打开!", "提示");

            }

        }



本文标题:检测80端口是否开启
标题路径:http://cdweb.net/article/gogdsg.html