How to tell connection timeout and socket timeout from exception trace stack?
<p>I used apache http client lib in my program. I set both connection timeout and socket timeout for network calls. My understanding is that, if there is connection timeout, the client didn't reach the backend server; if there is socket timeout, the client reached the backend server but the server was not responding or very slow.</p>

<p>I log the following exception trace stack. How can I tell which timeout (connection or socket) caused the exception? Thanks!</p>

<pre><code>java.net.SocketException: The operation timed out
at org.apache.harmony.luni.platform.OSNetworkSystem.connectStreamWithTimeoutSocketImpl(NativeMethod)
at org.apache.harmony.luni.platform.OSNetworkSystem.connectStreamWithTimeoutSocket(OSNetworkSystem.java:130)
at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:247)
at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:534)
at java.net.Socket.connect(Socket.java:1056)
at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:119)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:143)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:348)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
</code></pre>
