locked
C# TCP Socket Server with Windows RT

    Question

  • I have been searching quite while and I cannot seem to be able to find an answer to this simple question. Is there any way to create a TCP server in a Windows RT (Win / WP 8.1) C# application?

    PS. This will ultimately be used in the development of an HTML compatible WebSocket server.

    Thursday, July 24, 2014 3:59 PM

All replies

  • It would appear yes, I'm researching this currently as well.  I'm trying to create a RESTful HTTP interface for remote control of my app.   Check out the code in the Offline HTTP Server  http://offline.codeplex.com/.   It uses the StreamSocketListener.   In fact it might just already do everything need it to do.

    This is another good page.   http://www.dzhang.com/blog/2012/09/18/a-simple-in-process-http-server-for-windows-8-metro-apps
    Thursday, July 24, 2014 8:16 PM
  • Hi Gerhman,

    I don't think Windows Store App is designed to be a server. It's more act like a client app.

    Technically it could be achieved by the article suggested from im.thatoneguy, but let's think about the app lifecycle, Application lifecycle, Windows Store App lifecycle is managed by system and it has suspend or not running, we cannot ensure that the application act like a normal server never offline.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, July 31, 2014 2:43 AM
    Moderator
  • Rob am I seeing correctly in that example that a WinRT application can accept Https/SSL connections as a host? 
    Tuesday, August 05, 2014 11:52 PM
  • Yes.
    Tuesday, August 05, 2014 11:55 PM
    Owner
  • Where is it performing that negotiation.  As per the StreamSocketListener MSDN docs:

    The UpgradeToSslAsync method can only be used for client
    connections. This method can't be used to upgrade a
    connection accepted by the StreamSocketListener to an SSL
    connection. The UpgradeToSslAsync method only implements
    the client parts of the SSL protocol negotiation, not the
    server parts that would be needed to listen for and accept SSL connections.

    Wednesday, August 06, 2014 12:22 AM
  • Sorry. I misread your question. I thought you were asking if the example supported being a host and missed HTTPS specifically.

    --Rob

    Wednesday, August 06, 2014 12:40 AM
    Owner
  • Sorry. I misread your question. I thought you were asking if it supported being a host rather than if it supported HTTPS.
    Wednesday, August 06, 2014 12:40 AM
    Owner
  • No, worries, you just got my hopes up for a second. ;)  Thanks again for your time!
    Wednesday, August 06, 2014 12:50 AM