title: Receiving/sending data over sockets not completely working, only receiving the value once
body: <p>This is the the function for receiving the values from the client. But the problem is I'm receiving it only once. No matter how many time I send some data, the label on the MainWindows is being changed only once. </p>
  
  <p>What am I doing wrong here?</p>
  
  <pre><code>private void HandleClientComm(object client)
  {
      tcpClient = (TcpClient)client;
      NetworkStream clientStream = tcpClient.GetStream();
  
      byte[] message = new byte[4096];
      int bytesRead;
  
      while (true)
      {
          bytesRead = 0;
  
          try
          {
              bytesRead = clientStream.Read(message, 0, 4096);
          }
          catch
          {
              break;
          }
  
          if (bytesRead == 0)
          {
              break;
          }
  
          if (String.IsNullOrWhiteSpace(data))
          {
              ASCIIEncoding encoder = new ASCIIEncoding();
              data = encoder.GetString(message, 0, bytesRead);
  
              MainWindow.Change(data);
              tcpClient.Close();
          }
  
          tcpClient.Close();
  
      }
  </code></pre>
  
  <p>On the client side I have this following example:</p>
  
  <pre><code>try
  {
      TcpClient tcpclnt = new TcpClient();
      Console.WriteLine("Connecting.....");
      tcpclnt.Connect("127.0.0.1", 8001);
      Console.WriteLine("Connected");
      while (true)
      {
          Console.Write("Enter the string to be transmitted : ");
          String str = Console.ReadLine();
          Stream stm = tcpclnt.GetStream();
          ASCIIEncoding asen = new ASCIIEncoding();
          byte[] ba = asen.GetBytes(str);
          Console.WriteLine("Transmitting.....");
          stm.Write(ba, 0, ba.Length);
          stm.Flush();
          Console.WriteLine("Sent.....");
      }
  
      tcpclnt.Close();
      Console.Read();
  }
  catch (Exception e)
  {
      Console.WriteLine("Error..... " + e.StackTrace);
  }
  </code></pre>
  
  <p>Just a fast example, so when I enter the string name, the value changes the first time but when I enter a second time or if i exit the client program and reenter nothing changes, the value of the label content is equal to the first sent value.</p>