title: Why does HttpClient leave sockets open?
body: <p>When creating, using, and disposing several HttpClients I notice that there are sockets left open in the TIME_WAIT status.</p>
  
  <p>For example, after running the following:</p>
  
  <pre><code>using System.Net.Http;
  
  namespace HttpClientTest
  {
      public class Program
      {
          public static void Main(string[] args)
          {
              for (var i = 0; i &lt; 10; i++)
              {
                  using (var httpClient = new HttpClient())
                  {
                     var result = httpClient.
                          GetAsync("http://stackoverflow.com/").
                          Result;
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>I notice with netstat, that sockets are left open:</p>
  
  <pre><code>TCP    10.200.60.168:2722     151.101.193.69:http    TIME_WAIT
  TCP    10.200.60.168:2751     151.101.193.69:http    TIME_WAIT
  TCP    10.200.60.168:2752     151.101.193.69:http    TIME_WAIT
  TCP    10.200.60.168:2753     151.101.193.69:http    TIME_WAIT
  TCP    10.200.60.168:2754     151.101.193.69:http    TIME_WAIT
  TCP    10.200.60.168:2755     151.101.193.69:http    TIME_WAIT
  TCP    10.200.60.168:2756     151.101.193.69:http    TIME_WAIT
  TCP    10.200.60.168:2757     151.101.193.69:http    TIME_WAIT
  TCP    10.200.60.168:2758     151.101.193.69:http    TIME_WAIT
  TCP    10.200.60.168:2759     151.101.193.69:http    TIME_WAIT
  </code></pre>
  
  <p>Is this expected behavior? Do I need to explicitly set the Connection header value to close to prevent this?</p>
  
  <pre><code>httpClient.
      DefaultRequestHeaders.
      Connection.
      Add("close");
  </code></pre>