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);
    }

《android Httpclient 设置timeout》


发表评论

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

85 − = 77