I have a universal Windows application that should act as a TCP server.
m_Listener = new StreamSocketListener(); m_Listener.ConnectionReceived += (s, e) => ProcessRequestAsync(e.Socket); var bind = m_Listener.BindServiceNameAsync("8080").Wait();
Before starting the application, the port is not attached to anything:
C:\Users\jsant>netstat -a | grep 8080 ^C (Cancelled after some seconds because no reasults were found)
Then, when I launch the application:
C:\Users\jsant>netstat -a | grep 8080 TCP 0.0.0.0:8080 Laptop:0 LISTENING
So, the socket is listening on my computer! Trying to access it somehow leads to an error
C:\Users\jsant>telnet 127.0.0.1 8080 Connecting To 127.0.0.1...Could not open connection to the host, on port 8080: Connect failed C:\Users\jsant>telnet 192.168.1.167 8080 Connecting To 192.168.1.167...Could not open connection to the host, on port 8080: Connect failed C:\Users\jsant>telnet Laptop 8080 Connecting To Laptop...Could not open connection to the host, on port 8080: Connect failed C:\Users\jsant>telnet localhost 8080 Connecting To localhost...Could not open connection to the host, on port 8080: Connect failed
I have activated all the features to remove this as a possible reason.
The same code running in the console application works fine.
Also, running the MS example from https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/DatagramSocket had the same result. Inside the application, the socket was visible, outside, not!
Is there any restriction on starting the server in a universal Windows application, or am I missing something?
Thanks!
Joao
Edit I think that I was not clear enough. My problem is accessing the TCP server from an external application. The application may be telnet, web browser, etc. The server is inside a universal Windows application.
Edit # 2
I spent the last hour changing this example: https://ms-iot.imtqy.com/content/en-US/win10/samples/BlinkyWebServer.htm and ran it in my Raspberry Pi 2. I was able to access the web to the server from my computer. Running the same application on my computer, I was unable to connect. This is really weird!
Change # 3 I changed my application, left only Internet features (client and server) and no ads. Work in Raspberry Pi works flawlessly, on my local computer, still not luck (local or remote). And yes, the firewall is disabled :). Based on the comments of Jared, where he confirms the same problem with his computer, it seems to me that this is a mistake. I will continue the investigation.
Edit # 4 after learning the "CheckNetIsolation" command, adding the "PrivateNetworkClientServer" option to allow me access from an external device. However, it was not possible to access it from the local computer (even when adding the LoopbackExempt rule)