android Httpclient 设置timeout

    private HttpClient httpclient;
    private HttpPost httppost;
    private HttpParams httpParameters;
    private int timeoutConnection = 3000;
    private int timeoutSocket = 5000;
    public WidsetsHttpClient() {
        httpParameters = new BasicHttpParams();// Set the timeout in milliseconds until a connection is established.
        HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);// Set the default socket timeout (SO_TIMEOUT) // in milliseconds which is the timeout for waiting for data.
        HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
        httpclient = new DefaultHttpClient(httpParameters);
        httppost = new HttpPost(Display.serviceAPI);
    }

留下评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注

− 1 = 7