title: In some cases, rvest keeps connection open?
body: <p>rvest seems to be putting TCP FDs in CLOSE_WAIT state in some cases. </p>
  
  <p>Replication example:
  On R terminal do:</p>
  
  <pre><code>library(rvest)
  k&lt;-html("http://materialresourcing.com/tags/diy")
  </code></pre>
  
  <p>This will return.</p>
  
  <p>Now do NOT close the R prompt.</p>
  
  <p>Now open normal command Terminal and do:</p>
  
  <pre><code>lsof | grep materialresourcing
  </code></pre>
  
  <p>And you will find that it has a TCP handle in CLOSE_WAIT state, forever. (i.e till the R session is closed)</p>
  
  <p>And the rvest API doesn't seem to give control to force close connection.</p>
  
  <p>Any thoughts? Thanks!</p>
  
  <p>UPDATE: </p>
  
  <p>In fact just doing:</p>
  
  <pre><code>library(curl)
  k&lt;-curl_download("http://materialresourcing.com/tags/diy", "a.txt")
  </code></pre>
  
  <p>also causes it</p>
  
  <p>UPDATE IN RESPONSE TO @jeroen questions</p>
  
  <hr>
  
  <pre><code>&gt; library(curl)
  &gt; h &lt;- new_handle()
  &gt; l2&lt;-"http://rediff.com"
  &gt; curl_download(l2,"b.txt",handle=h)
  &gt; system("lsof | grep rediff")
  &gt; l3&lt;-"http://materialresourcing.com/tags/diy"
  &gt; curl_download(l3,"c.txt",handle=h)
  &gt; system("lsof | grep materialresourcing")
  R         17936          xxxx    7u     IPv4            3559514      0t0     TCP ip-10-0-xx:40844-&gt;vps.materialresourcing.com:http (CLOSE_WAIT)
  sh        18257          xxxx    7u     IPv4            3559514      0t0     TCP ip-10-0-xx:40844-&gt;vps.materialresourcing.com:http (CLOSE_WAIT)
  grep      18259          xxxx    7u     IPv4            3559514      0t0     TCP ip-10-0-xx:40844-&gt;vps.materialresourcing.com:http (CLOSE_WAIT)
  &gt; 
  </code></pre>
  
  <p>As you can see only for this link. CLOSE_WAIT shows. And same thing happens using rvest too. and gc() has no effect there.</p>