0
votes

My Socket Server can't receive any connection requests.

Tried to connect to the server with simple Socket Service => A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 127.0.0.1:1337. Enabled private internet and internet (client and server) in appxmanifest.

Service:

IPEndPoint serviceEndPoint = new IPEndPoint(IPAddress.Loopback, 1337);
Socket _serviceSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
_serviceSocket.Bind(serviceEndPoint);
_serviceSocket.Listen(254);
Socket clientSocket = null;
await _serviceSocket.AcceptAsync(clientSocket);

Client:

IPAddress _address = IPAddress.Loopback;
IPEndPoint _ep = = new IPEndPoint(_address, 1337);
Socket _clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
_clientSocket.Connect(_ep);
2
That certainly looks like it should work - and it works on regular .NET (non-UWP)... - Marc Gravell
And could you tell me pls why it doesn't work in UWP? - KRyTeX
I genuinely wish I could; your code isn't crazy, though - whatever it is: it is subtle and UWP-specific :( - Marc Gravell

2 Answers

0
votes

So I tried to debug it on my Raspberry Pi and it worked. I don't know why this code doesn't work on my PC.

0
votes

According to the docs, two UWP apps cannot communicate on the local host due to (what they call) network isolation. I have no experience with that but the documentation may show some configuration changes needed...