title: Is it possible to set timeout to disconnect established http connection?
body: <p>I am writing a file upload app. I can connect to server and upload file (apache http) using asyn method. <br>
  The server has set the limit of number of connection to 100. I want to set a connection timeout to disconnect the connection if the connection last for 60s.<br><br>
  Here is the flow:<br>
  (1) Android client establishes the connection to server. (Start count for 60s)<br>
  (2) If the connection still alive after 60s, then disconnect from the Android client</p>
  
  <p>I know that set timeout to HttpParams does not work. I have no idea of how to do it.<br>
  Anyone has idea of how to do it? Any solution or suggestion is welcome. Thanks!</p>
  
  <p>Here is the code snippet of how to upload the file:
  <br></p>
  
  <pre><code>try
  {
          HttpParams httpParameters = new BasicHttpParams();
          HttpConnectionParams.setConnectionTimeout(httpParameters, 60000);
          HttpConnectionParams.setSoTimeout(httpParameters, 60000);
  
  
          HttpClient client =  new DefaultHttpClient(httpParameters);  
          ...
          ByteArrayBody bab = new ByteArrayBody(byteArray, "photo.jpg");
          entity.addPart("photo", bab);
          httpPost.setEntity(entity);   
  
          startTime = System.currentTimeMillis();
  
  
          //ClientConnectionRequest connRequest = new ManagedClientConnection();
          //httpPost.setConnectionRequest((ClientConnectionRequest) connRequest.getConnection(3000, TimeUnit.MILLISECONDS));
  
          HttpResponse response = client.execute(httpPost, localContext);
  
          Handler mHandler = new Handler();
  
          BufferedReader reader = new BufferedReader(new InputStreamReader( response.getEntity().getContent(), "UTF-8"));  
          String result = "";  
          String tmp = "";
  
  
  
          while ((tmp = reader.readLine()) != null)
          {
              result += tmp;
          }
          reader.close();
  
          return result;
  
      } catch (Exception e) {  
          Log.e(TAG, "error time = " + (System.currentTimeMillis() - startTime));
          Log.e("httpUploadHandler", "Some error came up"); 
          Log.e("httpUploadHandler", e.toString()); 
  
      }   
  </code></pre>
  
  <p><br>
  I can disconnect the connection by calling:</p>
  
  <pre><code>client.getConnectionManager().shutdown();
  </code></pre>
  
  <p>But how can I count for 60s to disconnection the alive connection? Also, is it possible to know when the connection established?</p>