I have a Windows Universal Application that is supposed to 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 bind to anything:
C:\Users\jsant>netstat -a | grep 8080
^C (Cancelled after some seconds because no reasults were found)
Then, when I start 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, results in 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 capabilities to remove that as a possible reason.
The same code running on a console application is working just 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 limitation of running a server in a Windows Universal Application, or am I missing something?
Thanks!
Joao
Edit I think I wasn't clear enough. My problem is accessing the TCP Server from an external application. The application can either be a telnet, web browser, etc. The server is located inside the Windows Universal App.
Edit #2
I've spent the last hour changing this example : https://ms-iot.github.io/content/en-US/win10/samples/BlinkyWebServer.htm and running it in my Raspberry Pi 2 I was able to access the webserver from my computer. Running the same application in my computer I was unable to connect. This is really strange!
Edit #3 I've changed my application, left only the Internet (Client & Server) capability and no declarations. Running in the Raspberry Pi works flawlessly, in my local computer, still no luck (local or remote). And yes, the firewall is disabled :). Based on the Jared's comments, where he confirms the same problem with his computer, this seems to me to be a bug. I'll continue to investigate.
Edit #4 after learning about the command "CheckNetIsolation", adding the capability "PrivateNetworkClientServer" allowed me to have access from an external device. Still, unable to access it from the local computer (even with a LoopbackExempt rule added)