How to check the remote IP and port?

I need to check the remote IP and the port is available or not. If available, he will proceed to the next form. If it is not available, it should return to its original state. I tried using this

while (true) { IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties(); IPEndPoint[] ipEndPoints = ipProperties.GetActiveTcpListeners(); ------- ------- ------- } 

I am showing an example coding.it checking the local IP address and port and moving on to the next form. It will check the local port and IP access. If the port and IP are not available, it will go to the initial stage and fine.same thing will work, I have to check the remote port and IP.

+7
c # networking winforms tcp
source share
1 answer

Use the Ping .NET class to find out if the system is connected and whether it is connected, use PortScanner to check if the port is open. Check out these links for further reading and study.

http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping%28v=vs.110%29.aspx

http://social.msdn.microsoft.com/Forums/vstudio/en-US/8e4410bd-307f-4264-9575-cd9882653945/help-with-portscanner-in-c?forum=csharpgeneral

OR

 public static bool PingHost(string hostUri, int portNumber) { try { using (var client = new TcpClient(hostUri, portNumber)) return true; } catch (SocketException ex) { MessageBox.Show("Error pinging host:'" + hostUri + ":" + portNumber.ToString() + "'"); return false; } } 
+23
source share

All Articles