You can't ping a port because the ping operation does not operate at port level. You can however check to see if it is in use on the local computer or if it is open on the remote computer by means of connecting to the port using either TCP or UDP.
See if remote port is open:
Function CheckPortOpen(ByVal hostname As String, ByVal portnum As Integer) As Boolean
Dim ipAddr As IPAddress = CType(Dns.GetHostAddresses(hostname)(0), IPAddress)
Try
Dim sock As Socket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
Console.WriteLine("Testing " & hostname & ":" & portnum)
sock.Connect(ipAddr, portnum)
If (sock.Connected = True) Then
sock.Close()
sock = Nothing
Return True
End If
Catch sex As SocketException
If sex.ErrorCode = 10061 Then
Return False
Else
Return Nothing
End If
End Try
End Function