Java HttpURLConnection and pooling
<p>After reading all sort of docs on Java HttpURLConnection, I'm still quite confused as what kind of pooling it does and how it hands connections.</p>

<p>For example, the following code</p>

<pre><code>URL url = new URL(someUrl);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
OutputStream os = connection.getOutputStream();
InputStream is = connection.getInputStream();

/** Write something to os and flush */
/** Read from is */

os.close();
is.close();
connection.disconnect();
</code></pre>

<ol>
<li><p>Do both <code>os</code> and <code>is</code> need to be flushed and closed for the underlying socket to be reusable?</p></li>
<li><p>Will <code>connection.disconnect()</code> close the underlying socket (and hence make it unreusable)?  Does <code>keep-alive</code> affect this behavior?</p></li>
<li><p>If I use different URL objects, but with the same URL, will the <code>connection</code>s created from them share the underlying sockets?  How about when the host part of the URL is the same, but paths are different?</p></li>
<li><p>When will pooled connections be destroyed?</p></li>
<li><p>What's the system property that controls the size of the pool?</p></li>
</ol>

<p>Additionally, if you could also compare the Android version with Java it would be great.</p>

<p>Thanks</p>