locked
Can a Metro style app talk to another process via TCP/IP?

    Question

  • Is it possible for a Metro style app to talk to other processes via TCP/IP? If not, what other mechanisms are available?
    Thanks in advance!
    Oscar.

    Thursday, November 03, 2011 4:31 PM

Answers

  • Another way to look at this question is: can a Metro application talk to a Windows service and if so, what's the recommended way? For example, is there a way to use charms in order to exchange data between a Metro app and a Windows service?
    Thanks!
    Oscar.


    One idea behind this is that the Metro app should not have any dependency on a local service or application. I reckon the point there is that Metro may eventually be an independent platform and so cannot automatically assume the existence of a Win32 layer.

    Funnily, depending on a web-service is not foolproof either. What if the service is down, or if the internet connection is down?

    Personally speaking, I wish they gave us enough choices. Adding restriction after restriction because the designers of Metro think that no app would never need to think or work outside their narrow set of expectations is never a good idea. But since a lot of aggressive feedback has been provided on these restrictions, I am hopeful for something better by beta.

     


    http://blog.voidnish.com
    Thursday, November 10, 2011 1:25 PM
  • You are correct Nishant. Interprocess communication to / from a Metro style application is not permitted on the same box (if that was the purpose for this question). Fast forward to the Q&A section where Aleš Holeček fields a few questions at the end of this //build/ talk. It should cover most questions in this area.


    http://channel9.msdn.com/Events/BUILD/BUILD2011/TOOL-789C

     

    Thanks,

    David


    Friday, November 04, 2011 10:38 PM
    Moderator
  • Note that loopback is not permitted for Metro style apps. An exception is made for debugging, but your socket to 127.0.0.1 won't work on a deployed app.

    See How to enable loopback and troubleshoot network isolation for more details.

    --Rob

    Wednesday, March 14, 2012 3:58 PM
    Owner

All replies

  • You should  take a look at this sample:

    http://code.msdn.microsoft.com/StreamSocket-Sample-8c573931

    It's in JavaScript but the concepts are similar for C++.  You can use the Windows Runtime API used in this sample in the same way in C++ also.

    Thanks


    Raman Sharma | Program Manager, Visual C++ | @rasharm_msft

    (if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)
    Friday, November 04, 2011 5:51 AM
  • You should  take a look at this sample:

    http://code.msdn.microsoft.com/StreamSocket-Sample-8c573931

    It's in JavaScript but the concepts are similar for C++.  You can use the Windows Runtime API used in this sample in the same way in C++ also.

    Thanks


    Raman Sharma | Program Manager, Visual C++ | @rasharm_msft

    (if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)

    Raman, do you think that will work between processes on the same machine? I was under the impression that TCP connections to localhost are blocked under Metro.
    http://blog.voidnish.com
    Friday, November 04, 2011 3:59 PM
  • You are correct Nishant. Interprocess communication to / from a Metro style application is not permitted on the same box (if that was the purpose for this question). Fast forward to the Q&A section where Aleš Holeček fields a few questions at the end of this //build/ talk. It should cover most questions in this area.


    http://channel9.msdn.com/Events/BUILD/BUILD2011/TOOL-789C

     

    Thanks,

    David


    Friday, November 04, 2011 10:38 PM
    Moderator
  • Hi David,

    Yes, this was exactly the purpose of my original question. Are there any particular workarounds for this? What's the fundamental reason for the restriction? How could an application talk to (Windows) services on the same machine?

    Thank you for the pointer to the BUILD talk.

    Cheers,
    Oscar.

    Monday, November 07, 2011 5:55 PM
  • Another way to look at this question is: can a Metro application talk to a Windows service and if so, what's the recommended way? For example, is there a way to use charms in order to exchange data between a Metro app and a Windows service?
    Thanks!
    Oscar.

    Tuesday, November 08, 2011 8:36 PM
  • Another way to look at this question is: can a Metro application talk to a Windows service and if so, what's the recommended way? For example, is there a way to use charms in order to exchange data between a Metro app and a Windows service?
    Thanks!
    Oscar.


    One idea behind this is that the Metro app should not have any dependency on a local service or application. I reckon the point there is that Metro may eventually be an independent platform and so cannot automatically assume the existence of a Win32 layer.

    Funnily, depending on a web-service is not foolproof either. What if the service is down, or if the internet connection is down?

    Personally speaking, I wish they gave us enough choices. Adding restriction after restriction because the designers of Metro think that no app would never need to think or work outside their narrow set of expectations is never a good idea. But since a lot of aggressive feedback has been provided on these restrictions, I am hopeful for something better by beta.

     


    http://blog.voidnish.com
    Thursday, November 10, 2011 1:25 PM
  • Hi All,

    I just provide my experience for this kind of question, here is my solution for communicate between Metro and Desktop on Win8 Customer Preview.

    1. Write a application to listen TCP as information center which call "DesktopSvr"
    2. Metro app try to send message to localhost via streamsocket (P.S. localhost is not work, but 127.0.0.1 work well).
    3. "DesktopSvr" will pass desktop app via IPC or anyway you familiar.

    Note:

    • Since Metro UI will not get any TCP feedback if app under suspends, so communicate between metro app via TCP seems not possible here.

    Wednesday, March 14, 2012 6:56 AM
  • Note that loopback is not permitted for Metro style apps. An exception is made for debugging, but your socket to 127.0.0.1 won't work on a deployed app.

    See How to enable loopback and troubleshoot network isolation for more details.

    --Rob

    Wednesday, March 14, 2012 3:58 PM
    Owner
  • Hi Rob,

    I am a senior. NET developer and architect. For my clients who are large banks in the Nordic countries, is this feature (to be able to access a local web service on the same machine from Metro, WinRT) important. I certainly hope you (MS) don’t  lock it and I do not understand why you (MS) have to do that. It would have been a great way for us to fast porting our applications to Metro. Now we have to wait for better .NET support under WinRT (like local database, DB access/query and XML Schema API etc.). If this function is missing, we may as well porting our applications to IOS or Android, because we have to rewrite almost all the code if we cannot split the application into a client part running in Metro and Server part running in Windows. It is obvious that one should not develop a Metro App that rely on Win32, but not everyone develops consumer Apps, in LOB cases it is not Microsoft own affair lock out this type of function. The only way Microsoft can compete in the tablet market is to win (keep) the business customers (LOB) and we do not want a locked platform where we (the business) don’t have the key.

    Little bit angry and disappointed, long loyal MS developers.

    Patrik Carlander, Knowit Sweden.


    Wednesday, April 18, 2012 2:28 PM