title: C# server client fails on connect UWP
body: <p>I try to communicate using a simple TCP client server on UWP, I followed this link <a href="https://msdn.microsoft.com/en-us/windows/uwp/networking/sockets" rel="nofollow">UWP socket</a> but it looks like it doesn't works. I've added capabilities for both app to provide client &amp; server. Even if it doesn't appear in the code, I have handled the error, which give me the following : <code>System.Runtime.InteropServices.COMException (0x8007274C): A connection attemps has failed because the connected part has not answer after a certain amount of time or the connection has failed because host has not respond</code></p>
  
  <p><code>System.Runtime.InteropServices.COMException (0x8007274C): Une tentative de connexion a échoué car le parti connecté n’a pas répondu convenablement au-delà d’une certaine durée ou une connexion établie a échoué car l’hôte de connexion n’a pas répondu.</code></p>
  
  <p>As far I can look, it fails at the line <code>await clientSocket.ConnectAsync(serverHost, serverPort);</code></p>
  
  <p>At term, it should run the server on a Rasperry Pi 3 and the Client on a Windows 10 mobile (Lumia 950 XL build 14385) but until now I only terted on a surface pro 3 running Windows 10 Pro (build 14385)</p>
  
  <p>Client</p>
  
  <pre><code>try
  {
          StreamSocket clientSocket;
  
          clientSocket = new StreamSocket();
          HostName serverHost = new HostName("localhost");
          string serverPort = "5464";
          await clientSocket.ConnectAsync(serverHost, serverPort);
          Stream streamOut = clientSoket.OutputStream.AsStreamForWrite();
          StreamWriter writer = new StreamWriter(streamOut);
          string request = "test";
          await writer.WriteLineAsync(request);
          await writer.FlushAsync();
          Stream streamIn = clientSocket.InputStream.AsStreamForRead();
          StreamReader reader = new StreamReader(streamIn);
          string response = await reader.ReadLineAsync();
      }
      catch(Exception ex)
      {
          Console.WriteLine(ex.ToString());//handle
      }
  </code></pre>
  
  <p>Server</p>
  
  <pre><code>try
  {
      serverSocket = new StreamSocketListener();
      serverSocket.ConnectionReceived += ServerSocket_ConnectionReceived;
      await serverSocket.BindServiceNameAsync("5464");
  }
  catch(Exception e)
  {
      Console.WriteLine(e.ToString());//handle
  }
  
  private async void ServerSocket_ConnectionReceived(StreamSocketListener sender, StreamSocketListenerConnectionReceivedEventArgs args)
  {
      Stream inputStream = args.Socket.InputStream.AsStreamForRead();
      StreamReader reader = new StreamReader(inputStream);
      string request = await reader.ReadLineAsync();
          Stream outputStream = args.Socket.OutputStream.AsStreamForWrite();
      StreamWriter writter = new StreamWriter(outputStream);
      await writter.WriteLineAsync("Ok");
      await writter.FlushAsync();
  }
  </code></pre>