title: WriteLineAsync or ReadAsync unable to read string for TCP Communicator C#
body: <p>I am creating a TCP Server/Client to communicate with each other using multithread and I'm having trouble getting the Server to correctly read strings that my Client is sending. For example, I send the string &quot;testing&quot; from the Client to the Server. On the server console, it instead reads &quot;Received System.Net.Sockets.NetworkStream&quot;. I've been stuck on it for a couple hours and I am at a loss at how to approach this situation. Any help with be greatly appreciated.</p>
  <p>TLDR: Server and client can communicate with each other but server can't correctly read string sent from client.</p>
  <p>Server Code:</p>
  <pre><code>async Task EchoAsync(TcpClient client, CancellationToken ct)
          {
              var buf = new byte[4096];
              var stream = client.GetStream();
              while (!ct.IsCancellationRequested)
              {
                  var amountRead = await stream.ReadAsync(buf, 0, buf.Length, ct);
                  WriteToConsole(&quot;Received &quot; + stream.ToString(), 0);
                  if (amountRead == 0)
                  {
                      break; // End of stream
                  }
                  await stream.WriteAsync(buf, 0, amountRead, ct);
              }
          }
  </code></pre>
  <p>Client Code:</p>
  <pre><code>private async void ClientToServerMsg_btn_Click(object sender, RoutedEventArgs e)
          {
              using (var NetworkStream = clientSocket.GetStream())
              using (var writer = new StreamWriter(NetworkStream))
              {
                  //writer.AutoFlush = true;
                  WriteToConsole(&quot;Writing to server...&quot;, 1);
                  await writer.WriteLineAsync(ClientToServerMsg.Text);
  
              }
          }
  </code></pre>