Check Opened Port

public static bool CheckOpenedPort(this int port)
            {
                IPGlobalProperties ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties();
                IPEndPoint[] tcpConnInfoArray = ipGlobalProperties.GetActiveTcpListeners();

                foreach (IPEndPoint endpoint in tcpConnInfoArray)
                {
                    if (endpoint.Port == port)
                    {
                        return true;
                    }
                }
                return false;
            }
Example:
 int portNumber = 507;
 MessageBox.Show(portNumber.CheckOpenedPort().ToString());

Description

بررسی باز بودن پورت

Details

Double click on the code to select all.

 

;