title: Sending and receiving data over a network using TcpClient
body: <p>I need to develop a service that will connect to a TCP server. Main tasks are reading incoming messages and also sending commands to the server in ten minutes, like a synchronize command. For example, I used the TcpClient object as shown below:</p>
  
  <pre><code>...
  TcpClient tcpClient = new TcpClient();
  tcpClient.Connect("x.x.x.x", 9999);
  networkStream = tcpClient.GetStream();
  clientStreamReader = new StreamReader(networkStream);
  clientStreamWriter = new  StreamWriter(networkStream);
  while(true)
  {
     clientStreamReader.Read()
  }
  </code></pre>
  
  <p>Also, when I need to write out something in any method, I use:</p>
  
  <pre><code> clientStreamWriter.write("xxx");
  </code></pre>
  
  <p>Is this usage correct? Or is there a better way?</p>