locked
Connecting to a Remote Server

    Question

  • Hey everybody,

    at the Moment I'm trying to write a universal App for remote controling a Desktop App.

    The Desktop app has a build in Interface to communicate with by simple terminal Textinstructions. When I use Putty(Telnet) everything works great. I can connect and send/recive Informations.

    First question: Do i Need the StreamSocket class for this? I tried it several times with different Settings, but can't connect to the Server getting a exception: ".... hresult: 0x8007274C", what means that the remote Server doesn't respond. Here is the Connection part of my code:

    class CommunicationSocket
        {
    
            public string error;
            private HostName ServerName;
            StreamSocket _socket;
                    
            
            public async void Connect(string hostName, string portNumber)
            {
    
             //Connect to IP 192.168.xxx.xxx on Port 2000
     
                ServerName = new HostName("192.168.xxx.xxx");
                try
                {               
                    _socket = new StreamSocket();
                    await _socket.ConnectAsync(ServerName, "2000");
    
                    error = "Connected";
                    
                }
                catch(Exception exception)
                {
                    if (SocketError.GetStatus(exception.HResult) == SocketErrorStatus.Unknown)
                    {
                        throw;
                    }
                    error = exception.Message;                
    
                }
                MessageDialog Dialog = new MessageDialog(error);
                await Dialog.ShowAsync();
    
                    
            }
        }

    Am i on the right way?

    Cheers form Germay!

    Sunday, May 04, 2014 11:57 AM

Answers

  • Make sure your firewall isn't blocking this and that you have appropriate capabilities for local networking (though that would probably be an AccessDenied).

    Your basic connection code looks reasonable. See How to connect with a stream socket and the StreamSocket sample. You can use that sample code and enter your real host name and address.

    --Rob

    Monday, May 05, 2014 7:22 AM
    Owner

All replies

  • Make sure your firewall isn't blocking this and that you have appropriate capabilities for local networking (though that would probably be an AccessDenied).

    Your basic connection code looks reasonable. See How to connect with a stream socket and the StreamSocket sample. You can use that sample code and enter your real host name and address.

    --Rob

    Monday, May 05, 2014 7:22 AM
    Owner
  • Hi signsy,

    Did you enable privateNetworkClientServer capability declaration before you execute the code?

    I would suggest you to go through Handling exceptions in network apps to see if it helps.

    --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.

    Monday, May 05, 2014 7:37 AM
    Moderator
  • Oh maaaan,

    such a stupid Thing. Everything works fine, but my Notebook doesn't.

    I tought i checked this several times, but it seems that i alway did connect from my Notebook to my PC and not the other way...

    Wasted several houres just because of that. DAMN!

    anyway. Thank's Guys!

    Monday, May 05, 2014 4:23 PM