title: I would like to know why `while` in NetworkStream does not execute immediately and waits
body: <p>I have a server program.
  And there is also a client program.</p>
  <p>The server was created using <code>TcpListener</code>, and the client was created using <code>TcpClient</code>.</p>
  <p>After several experiments, <code>while</code> in the code below is not executed until <code>stream.write()</code> is executed in the client program.</p>
  <p>Can you tell by what principle this is?</p>
  <pre class="lang-cs prettyprint-override"><code>while (true) // That's no!
  {
    Console.WriteLine(&quot;waiting connection...&quot;);
  
    TcpClient client = server.AcceptTcpClient();
    Console.WriteLine(&quot;Connected!&quot;);
  
    data = null;
  
    NetworkStream stream = client.GetStream();
  
    int i;
    // This is while
    while ((i = stream.Read(bytes, 0, bytes.Length)) != 0)
    {
      data = Encoding.UTF8.GetString(bytes, 0, i);
      Console.WriteLine(&quot;Received: {0}&quot;, data);
    }
  
    Console.WriteLine(&quot;This statement is only executed when stream.write() is executed.&quot;);
  
    client.Close();
  }
  </code></pre>