0

サーバー接続には、show blow のように接続を使用します。

    HttpParams params = new BasicHttpParams();
    ConnManagerParams.setMaxTotalConnections(params, 10);
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);

    params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, Integer.valueOf(60000));
    params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, Integer.valueOf(60000));
    params.setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true);

    //eate and initialize scheme registry 
    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));

    // Create an HttpClient with the ThreadSafeClientConnManager.
    // This connection manager must be used if more than one thread will
    // be using the HttpClient.
    cm = new ThreadSafeClientConnManager(params, schemeRegistry);
    httpClient = new DefaultHttpClient(cm, params);

ThreadSafeClientConnManager API は次のように述べています。

ThreadSafeClientConnManager maintains a maximum limit of connection on a per route 
basis and in total. Per default this implementation will create no more than than 
2 concurrent connections per given route and no more 20 connections in total. For many 
real-world applications these limits may prove too constraining, especially if they use      
HTTP as a transport protocol for their services. Connection limits, however, can be     
adjusted using HTTP parameters.

ホストあたりの最大接続数を 2 以上に変更するにはどうすればよいですか?

前もって感謝します!

4

0 に答える 0