For UWP, I try to open 2 ports to listen incoming connection:
BindServiceNameAsync("6000")
BindServiceNameAsync("6001")
Unfortunately I cannot make it work, whichever listening port get first connection with TCP client the other port cannot be connected.
My code is like this:
Public Async Sub IDPserverStart()
Dim socketListener = New Windows.Networking.Sockets.StreamSocketListener
AddHandler socketListener.ConnectionReceived, AddressOf TCPconnectedProcess
Try
Await socketListener.BindServiceNameAsync("6001")
Catch ex As Exception
socketListener.Dispose()
Debug.WriteLine("IDPserverStart() ERR: " & ex.Message)
End Try
End Sub
Public Async Sub OPSserverStart()
Dim socketListener = New Windows.Networking.Sockets.StreamSocketListener
AddHandler socketListener.ConnectionReceived, AddressOf OPSconnectedProcess
Try
Await socketListener.BindServiceNameAsync("6000")
Catch ex As Exception
socketListener.Dispose()
Debug.WriteLine("OPSserverStart() ERR: " & ex.Message)
End Try
End Sub
There is no limitation for listening port per apps on Windows IoT Core. The reason is the firewall rules for connection security policy. Please add the firewall rule to Windows IoT Core like below cmdlet by using PowerShell for windows IoT or running command in Device Portal(Processes->Run command):
netsh advfirewall firewall add rule name="Open Port 6001" dir=in action=allow protocol=TCP localport=6001
BTW.You can use the following cmdlet to check the rules in your device.
netsh advfirewall firewall show rule status=enabled name=all