{"id":1238,"date":"2022-10-07T14:14:40","date_gmt":"2022-10-07T13:14:40","guid":{"rendered":"https:\/\/ibex.tech\/csharp\/?p=1238"},"modified":"2022-10-08T15:23:47","modified_gmt":"2022-10-08T14:23:47","slug":"sockets","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/uwp-programming-in-c\/projects-general\/interprocess-communication-ipc\/sockets","title":{"rendered":"Sockets"},"content":{"rendered":"\n<p>Using localhost 127.0.0.1 sockets to communicate works when you debug, but when you go to install your UWP app its blocked!<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">UDP sockets<\/h4>\n\n\n\n<p>UDP isn&#8217;t permitted from UWP app to UWP app (stated <a rel=\"noreferrer noopener\" href=\"https:\/\/learn.microsoft.com\/en-us\/uwp\/schemas\/appxpackage\/uapmanifestschema\/element-uap4-loopbackaccessrules\" target=\"_blank\">here<\/a> &#8211; &#8220;The UDP protocol is not supported&#8221;.)<\/p>\n\n\n\n<p>In our testing, UDP client is possible, if you use <a rel=\"noreferrer noopener\" href=\"https:\/\/telerik-fiddler.s3.amazonaws.com\/fiddler\/addons\/enableloopbackutility.exe\" target=\"_blank\">the telerik AppContainer Loopback Utility<\/a> to enable loopback usage for the UWP app (we found &#8220;CheckNetIsolation LoopbackExempt&#8221; commands didn&#8217;t work (resulted in app not found when listing exemptions for us), but this telerik app worked great). After a reboot it will then connect successfully.<\/p>\n\n\n\n<p><em>Note that when debugging with Visual Studio you&#8217;ll find that UDP client works fine because Visual Studio enables the loopback usage. Its once the UWP app is installed you discover the loopback address can&#8217;t be used and the the telerik AppContainer Loopback Utility is needed.<\/em><\/p>\n\n\n\n<p>However, implementing a UDP server on 127.0.0.1 in our UWP app didn&#8217;t work for us under any circumstances &#8211; our Win32 apps packets did not reach its port when sent to 127.0.0.1.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">TCP Sockets<\/h5>\n\n\n\n<p>TCP connectivity to 127.0.0.1 is possible if your app is sideloaded (not installed via the app store), we&#8217;ve done this to implement comms between a UWP app and a Win32 app, with the Win32 app acting as TCP server (listening for a connection).  You still need to use the telerik AppContainer Loopback Utility (or equivalent) to enable loopback usage for the UWP app once it&#8217;s been installed. After a reboot, it will then connect successfully.<\/p>\n\n\n\n<p>Here are some further resources :<\/p>\n\n\n\n<p><a href=\"https:\/\/learn.microsoft.com\/en-us\/windows\/uwp\/communication\/interprocess-communication\">https:\/\/learn.microsoft.com\/en-us\/windows\/uwp\/communication\/interprocess-communication<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/www.mysysadmintips.com\/windows\/clients\/912-windows-10-uwp-apps-can-t-connect-to-local-ip-loopback-restriction\">https:\/\/www.mysysadmintips.com\/windows\/clients\/912-windows-10-uwp-apps-can-t-connect-to-local-ip-loopback-restriction<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using localhost 127.0.0.1 sockets to communicate works when you debug, but when you go to install your UWP app its blocked! UDP sockets UDP isn&#8217;t permitted from UWP app to UWP app (stated here &#8211; &#8220;The UDP protocol is not supported&#8221;.) In our testing, UDP client is possible, if you use the telerik AppContainer Loopback [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[151],"tags":[],"class_list":["post-1238","post","type-post","status-publish","format-standard","hentry","category-interprocess-communication-ipc"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/1238","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/comments?post=1238"}],"version-history":[{"count":6,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/1238\/revisions"}],"predecessor-version":[{"id":1267,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/1238\/revisions\/1267"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=1238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=1238"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=1238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}