title: TcpClient SocketException with timeout after 20s no matter what
body: <p>I'd like to wait for a slow response from a client with <code>TcpClient</code> but get a timeout after about 20s no matter how I configure it. This is my attempt:</p>
  
  <pre><code>using (var client = new TcpClient { ReceiveTimeout = 9999999, SendTimeout = 9999999 })
  {
      await client.ConnectAsync(ip, port);
      using (var stream = client.GetStream())
      {
          // Some quick read/writes happen here via the stream with stream.Write() and stream.Read(), successfully.
  
          // Now the remote host is calculating something long and will reply if finished. This throws the below exception however instead of waiting for &gt;20s.
          var bytesRead = await stream.ReadAsync(new byte[8], 0, 8);
      }
  }
  </code></pre>
  
  <p>The exception is an <code>IOException</code>:</p>
  
  <blockquote>
    <p>Unable to read data from the transport connection: A connection
    attempt failed because the connected party did not properly respond
    after a period of time, or established connection failed because
    connected host has failed to respond.</p>
  </blockquote>
  
  <p>...which contains a <code>SocketException</code> inside:</p>
  
  <blockquote>
    <p>A connection attempt failed because the connected party did not
    properly respond after a period of time, or established connection
    failed because connected host has failed to respond</p>
  </blockquote>
  
  <p><code>SocketErrorCode</code> is <code>TimedOut</code>.</p>
  
  <p>The 20s <a href="https://serverfault.com/a/671453/203275">seems to be an OS default on Windows</a> but isn't it possible to override it from managed code by interacting with <code>TcpClient</code>? Or how can I wait for the response otherwise?</p>
  
  <p>I've also tried the old-style <code>BeginRead</code>-<code>EndRead</code> way and the same happens on <code>EndRead</code>. The problem is also not caused by Windows Firewall or Defender.</p>