title: C# Reading stream from TcpClient
body: <p>I'm making a server - client program using <code>TcpClient</code> and server.</p>
  
  <p>To send from the server I use:</p>
  
  <pre><code>static void send(string data)
  {
      sw.WriteLine(data + Environment.NewLine);   
  }
  </code></pre>
  
  <p>And when the client connects I'm sending some text:</p>
  
  <pre><code>client = listener.AcceptTcpClient();
  sr = new StreamReader(client.GetStream());
  sw = new StreamWriter(client.GetStream());
  
  string line;
  
  try 
  {
      send("Hello world");
  } //More code
  </code></pre>
  
  <p>And to read from client:</p>
  
  <pre><code>string data;
  data = sr.ReadLine();
  
  if(data != string.Empty || data != null)
  {
      MessageBox.Show(data);
  }
  </code></pre>
  
  <p>I tried putting inside while(true) and it froze, I tried putting inside a timer tick loop and it froze...</p>
  
  <p>How do I fix this?</p>
  
  <p>P.S: The client and the server are 2 different projects.</p>