title: How to know if the client call connection close on TcpListener?
body: <p>I wrote simple application that using TcpListener. 
  The application is wait till some client will connect - and while the client is connected the application will listen to his sending stream. </p>
  
  <p>In the code - i using while loop to check if the client is connected. 
  But event when i close the connection on the client side i get connected == true</p>
  
  <p>But .. on the client close => i see that the server get byte stream with byte.length == 0</p>
  
  <p>Code ... </p>
  
  <pre><code>private async void button1_Click(object sender, EventArgs e)
  {
          TcpListener tcpListener = new TcpListener(IPAddress.Any, 5501);
          tcpListener.Start(1);       // listen one client only
  
          TcpClient client = await tcpListener.AcceptTcpClientAsync();
  
          NetworkStream networkStream = client.GetStream();
  
          while (client.Connected)    // after connected =&gt; this is always true .. event if i close the connection on the client side 
          {
              // do something ... 
          }
  
          System.Console.WriteLine("No Connected");
  }
  </code></pre>