I have been given the task of creating a small application in VB.NET where users can enter a port number into a text field and it checks against the machines IP address to see if that port is blocked or not. I did develop a method using a TCPListener, but it seems it is not working as it needs to be. Currently i have:
Dim tcpList As TcpListener = New TcpListener(System.Net.IPAddress.Parse(Host), PortNumber)
tcpList.Start()
tcpList.Stop()
Return True
However that seems to show the Port as blocked if something is already listening in on it. Can anybody think of a way of doing this properly?
Thanks!
Try this:
If My.Computer.Network.Ping("198.01.01.01") Then
MsgBox("Server pinged successfully.")
Else
MsgBox("Ping request timed out.")
End If
Or
If My.Computer.Network.Ping("www.cohowinery.com", 1000) Then
MsgBox("Server pinged successfully.")
Else
MsgBox("Ping request timed out.")
End If
also see:https://msdn.microsoft.com/en-us/library/s9xkzk4s(v=vs.90).aspx