Question

How can I test communication, after setting firewall exceptions, for a given port?

 

Answer

The easiest way to test if two machines can communicate over a given port is to run the below command in PowerShell on the client machine:

Test-NetConnection -Computer <host> -Port <port> -InformationLevel Detailed


If there is not already a component installed on the host and configured to listen on the desire port, the following can be run in PowerShell on the host machine to open a listener on the desired port.  Note that the specified listener will continue running until the PowerShell window is closed:

$Port = <port>

$Listener = [System.Net.Sockets.TcpListener]$Port;
$Listener.Start();
while ($true)
{
    $client = $Listener.AcceptTcpClient();
    Write-Host "Received connection from" ($client.Client.RemoteEndPoint).Address.ToString();
    $client.Close();
}
$Listener.Stop();