title: How to connect to UWP apps between the same network
body: <p>I try to make a connection between to UWP apps, one is the client on a laptop, the second is the server on a raspberry Pi 3 model B with Windows Iot, and the two devices are on the same network.</p>
  
  <p>I have tried this code on the server app : </p>
  
  <pre class="lang-cs prettyprint-override"><code>using System;
  using System.Net;
  using System.Net.Sockets;
  using System.Threading.Tasks;
  using Windows.UI.Xaml;
  using Windows.UI.Xaml.Controls;
  
  namespace IOTServer
  {
      public sealed partial class MainPage : Page
      {
          Socket listenerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
          IPEndPoint ipEnd;
          string hôte, iptest;
          Task&lt;System.Net.IPHostEntry&gt; iphe;
          public MainPage()
          {
              this.InitializeComponent();
              hôte = Dns.GetHostName();
              iphe = Dns.GetHostEntryAsync(hôte);
              iptest = iphe.Result.AddressList[0].ToString();
              ipEnd = new IPEndPoint(IPAddress.Parse("192.168.1.102"), 8888);
              listenerSocket.NoDelay = true;
              listenerSocket.Bind(ipEnd);
              listenerSocket.Listen(0);
          }
  
          private void Button_Click(object sender, RoutedEventArgs e)
          {
              Socket clientSocket = listenerSocket.Accept();
              Byte[] Buffer = new byte[clientSocket.SendBufferSize];
              int readByte = clientSocket.Receive(Buffer);
              tbData.Text += readByte.ToString() + Convert.ToChar(13);
          }
      }
  }
  </code></pre>
  
  <p>And this code for the client app : </p>
  
  <pre class="lang-cs prettyprint-override"><code>using System.Net;
  using System.Net.Sockets;
  using System.Threading.Tasks;
  using Windows.UI.Xaml;
  using Windows.UI.Xaml.Controls;
  
  namespace IOTClient
  {
      public sealed partial class MainPage : Page
      {
          Socket client= new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
          IPEndPoint ipEnd;
          string hôte, iptest;
          Task&lt;System.Net.IPHostEntry&gt; iphe;
          public MainPage()
          {
              this.InitializeComponent();
              hôte = Dns.GetHostName();
              iphe = Dns.GetHostEntryAsync(hôte);
              iptest = iphe.Result.AddressList[0].ToString();
              ipEnd = new IPEndPoint(IPAddress.Parse("192.168.1.102"), 8888);
          }
  
          private void BSend_Click(object sender, RoutedEventArgs e)
          {
              client.Connect(ipEnd);
              client.Send(System.Text.Encoding.UTF8.GetBytes(tbSend.Text));
          }
      }
  }
  </code></pre>
  
  <p>When I click on the bSend button, the client app crash with this exception error : </p>
  
  <p><a href="https://i.stack.imgur.com/hS08W.png" rel="nofollow noreferrer">Error message for the socket exception</a></p>
  
  <p>I don't understand this, I can ping the raspberry in command line, and execute the server app directly from VS2017 to the raspberry.</p>
  
  <p>Someone can help me please ?
  Thanks in advance.</p>
  
  <p>Please apologize my english, i'm french guy ;)</p>
  
  <p>Théo</p>