Try
Dim ip As System.Net.IPHostEntry = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName())
Dim ipaddy As Net.IPAddress = ip.AddressList(0)
Dim ep As New Net.IPEndPoint(ipaddy, 80)
Dim listner As New Net.Sockets.TcpListener(ep)
listner.Start()
Catch ex As SocketException
If ex.ErrorCode = 10048 Then '/// error number for Port already in use.
MessageBox.Show("The port you attempted to connect to is already in use!")
Else
MessageBox.Show(ex.ErrorCode & " " & ex.Message)
End If
End Try