title: How to send data from .NET Server app to Windows 8 Metro Client app with Sockets?
body: <p>I am trying to send simple string message from my desktop app using sockets here is the <strong>server side code</strong> which sends data to the client:        </p>
  
  <pre><code>    swSenderSender = new StreamWriter(tcpClients[i].GetStream());
      swSenderSender.WriteLine(From + " says: " + Message);
      swSenderSender.Flush();
      swSenderSender = null;
  </code></pre>
  
  <p>I have Metro application - <strong>Client side code</strong> using DataReader:</p>
  
  <pre><code>    var dr = new DataReader(socket.InputStream);
      var stringHeader = await dr.LoadAsync(4);
      int strLength = dr.ReadInt32();
      uint numStrBytes = await dr.LoadAsync((uint)strLength);
      string msg = dr.ReadString(numStrBytes);
  </code></pre>
  
  <p>Here is the problem. DataReader needs to know how long is the string which were send. On the other side the StreamWriter cant sand nothing different than a simple string /or string with new lane. How to connect these two codes? Or maybe there is annother way to do this. Please help. I don't know how to format the data to be able to send it between the client and the server.</p>