title: Sending Array of Bytes from Client to server?
body: <p>I've a tcp based client-server application. I'm able to send and receive strings, but don't know how to send an array of bytes instead. </p>
  
  <p>I'm using the following function to send a string from the client to the server: </p>
  
  <pre><code>static void Send(string msg)
  {
      try
      {
          StreamWriter writer = new StreamWriter(client.GetStream());
          writer.WriteLine(msg);
          writer.Flush();
      }
      catch
      {
      }
  }
  </code></pre>
  
  <p><strong>Communication example</strong> </p>
  
  <p><em>Client sends a string:</em></p>
  
  <pre><code>Send("CONNECTED| 84.56.32.14")
  </code></pre>
  
  <p><em>Server receives a string:</em></p>
  
  <pre><code>void clientConnection_ReceivedEvent(Connection client, String Message)
  {
      string[] cut = Message.Split('|');
      switch (cut[0])
      {
          case "CONNECTED":
              Invoke(new _AddClient(AddClient), client, null);
              break;
          case "STATUS":
              Invoke(new _Status(Status), client, cut[1]);
              break;
      }
  }
  </code></pre>
  
  <p>I need some help to modify the functions above in order to <em>send and receive an array of bytes</em> in addition to strings. I want to make a call like this: </p>
  
  <pre><code>Send("CONNECTED | 15.21.21.32", myByteArray);
  </code></pre>