title: Sending multiple data in TCPSocket
body: <p>I'm trying to create a chat with file transfer application using TCPSocket and here is my code..</p>
  
  <p>SENDER:</p>
  
  <pre><code>public void sendData(string message)
  {
      StreamWriter streamWriter = new StreamWriter(netStream); // netStream is 
                                                               // connected   
      streamWriter.WriteLine(message);
      streamWriter.WriteLine(message);
      logs.Add(string.Format("Message Sent! :{0}", message));
      //netStream.Flush();
      streamWriter.Flush();
  }
  </code></pre>
  
  <p>RECEIVER:</p>
  
  <pre><code>private void ReceiveData()
  {
      StreamReader streamReader = new StreamReader(ChatNetStream);
  
      StringBuilder dataAppends = new StringBuilder();
      bool doneTransfer = false;
      string data;
      while (!doneTransfer)
      {
          while ((data = streamReader.ReadLine()) != null)
          {
              dataAppends.Append(data);
          }
          doneTransfer = true;
          //ChatNetStream.Close();
          //streamReader
      }
  
      //do whatever i want with dataAppends.ToString() here..
     ReceiveData()
  }
  </code></pre>
  
  <p>the problem is i always turn into infinite loop inside this statement</p>
  
  <pre><code>while ((data = streamReader.ReadLine()) != null)
  {
      dataAppends.Append(data);
  }
  </code></pre>
  
  <p>even if i put streamWriter.Flush() on my sender..</p>
  
  <p>do i need to close/dispose the netStream/NetworkStream? </p>
  
  <p>anyway, can i use only 1 socket or connection to send a File and send a chat at the same time..? or do i need to use a new socket connection everytime i send a file..</p>