Socket Communication on UWP (Universal Windows Platform)

后端 未结 1 1619
忘了有多久
忘了有多久 2021-01-07 11:14

What I want to implement is UWP-based programs and other C# programs are trying to communicate with Socket on one PC (Windows 10 Pro).

I have tried to make UDP commu

相关标签:
1条回答
  • 2021-01-07 11:33

    I saw a statement that it is impossible that socket communication between other programs on the same device

    It is right. According to the note of DatagramSocket official sample:

    Network communications using an IP loopback address cannot normally be used for interprocess communication between a Universal Windows Platform (UWP) app and a different process (a different UWP app or a desktop app) because this is restricted by network isolation.

    We cannot communicate a uwp app with other apps in a same machine.

    Also, if it is right, Would you recommend other ways to solve this problem?

    By testing on my side, if you use a c# console project as server and a uwp app as client, they can communicate successfully both with StreamSocket and DatagGramSocket. But following special steps need to pay attention to let it work.

    • Please ensure the Internet(Client&Server) and Private Internet(Client&Server) capabilities are enabled.

    • Run the server side as administrator.

    • Allow the network access promoted by windows when you run the server.

    I wrote a demo which contains server side and client side of UDP and TCP. You can download here for testing.

    And the results.

    Although this can work, I recommend you to not use except for developing purpose.

    0 讨论(0)
提交回复
热议问题