当前位置: 首页>>代码示例>>Java>>正文


Java HttpConnectionParams.getConnectionTimeout方法代码示例

本文整理汇总了Java中org.apache.http.params.HttpConnectionParams.getConnectionTimeout方法的典型用法代码示例。如果您正苦于以下问题:Java HttpConnectionParams.getConnectionTimeout方法的具体用法?Java HttpConnectionParams.getConnectionTimeout怎么用?Java HttpConnectionParams.getConnectionTimeout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.http.params.HttpConnectionParams的用法示例。


在下文中一共展示了HttpConnectionParams.getConnectionTimeout方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: connectSocket

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
/**
 * @see SocketFactory#connectSocket(Socket, String, int,
 *      InetAddress, int, HttpParams)
 */
public Socket connectSocket(Socket sock, String host, int port, InetAddress localAddress, int localPort,
		HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
	int connTimeout = HttpConnectionParams.getConnectionTimeout(params);
	int soTimeout = HttpConnectionParams.getSoTimeout(params);
	InetSocketAddress remoteAddress = new InetSocketAddress(host, port);
	SSLSocket sslsock = (SSLSocket) ((sock != null) ? sock : createSocket());

	if ((localAddress != null) || (localPort > 0)) {
		// we need to bind explicitly
		if (localPort < 0) {
			localPort = 0; // indicates "any"
		}
		InetSocketAddress isa = new InetSocketAddress(localAddress, localPort);
		sslsock.bind(isa);
	}

	sslsock.connect(remoteAddress, connTimeout);
	sslsock.setSoTimeout(soTimeout);
	return sslsock;

}
 
开发者ID:warnerbros,项目名称:cpe-manifest-android-experience,代码行数:26,代码来源:EasySSLSocketFactory.java

示例2: connectSocket

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
/**
 * @see org.apache.http.conn.scheme.SocketFactory#connectSocket(java.net.Socket, java.lang.String, int,
 *      java.net.InetAddress, int, org.apache.http.params.HttpParams)
 */
public Socket connectSocket(Socket sock, String host, int port, InetAddress localAddress, int localPort,
                            HttpParams params) throws IOException {
    int connTimeout = HttpConnectionParams.getConnectionTimeout(params);
    int soTimeout = HttpConnectionParams.getSoTimeout(params);
    InetSocketAddress remoteAddress = new InetSocketAddress(host, port);
    SSLSocket sslsock = (SSLSocket) ((sock != null) ? sock : createSocket());

    if ((localAddress != null) || (localPort > 0)) {
        // we need to bind explicitly
        if (localPort < 0) {
            localPort = 0; // indicates "any"
        }
        InetSocketAddress isa = new InetSocketAddress(localAddress, localPort);
        sslsock.bind(isa);
    }

    sslsock.connect(remoteAddress, connTimeout);
    sslsock.setSoTimeout(soTimeout);
    return sslsock;

}
 
开发者ID:benjamarle,项目名称:typhon,代码行数:26,代码来源:EasySSLSocketFactory.java

示例3: connectSocket

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
/**
 * @see org.apache.http.conn.scheme.SocketFactory#connectSocket(java.net.Socket,
 *      java.lang.String, int, java.net.InetAddress, int,
 *      org.apache.http.params.HttpParams)
 */
public Socket connectSocket(Socket sock, String host, int port,
                InetAddress localAddress, int localPort, HttpParams params)
                throws IOException, UnknownHostException, ConnectTimeoutException {
        int connTimeout = HttpConnectionParams.getConnectionTimeout(params);
        int soTimeout = HttpConnectionParams.getSoTimeout(params);

        InetSocketAddress remoteAddress = new InetSocketAddress(host, port);
        SSLSocket sslsock = (SSLSocket) ((sock != null) ? sock : createSocket());

        if ((localAddress != null) || (localPort > 0)) {
                // we need to bind explicitly
                if (localPort < 0) {
                        localPort = 0; // indicates "any"
                }
                InetSocketAddress isa = new InetSocketAddress(localAddress,
                                localPort);
                sslsock.bind(isa);
        }

        sslsock.connect(remoteAddress, connTimeout);
        sslsock.setSoTimeout(soTimeout);
        return sslsock;

}
 
开发者ID:codedavid,项目名称:PanoramaGL,代码行数:30,代码来源:EasySSLSocketFactory.java

示例4: connectSocket

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
/**
 * @since 4.1
 */
@Override
public Socket connectSocket(
        final Socket socket,
        final InetSocketAddress remoteAddress,
        final InetSocketAddress localAddress,
        final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
    Args.notNull(remoteAddress, "Remote address");
    Args.notNull(params, "HTTP parameters");
    final HttpHost host;
    if (remoteAddress instanceof HttpInetSocketAddress) {
        host = ((HttpInetSocketAddress) remoteAddress).getHttpHost();
    } else {
        host = new HttpHost(remoteAddress.getHostName(), remoteAddress.getPort(), "https");
    }
    final int socketTimeout = HttpConnectionParams.getSoTimeout(params);
    final int connectTimeout = HttpConnectionParams.getConnectionTimeout(params);
    socket.setSoTimeout(socketTimeout);
    return connectSocket(connectTimeout, socket, host, remoteAddress, localAddress, null);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:23,代码来源:SSLSocketFactory.java

示例5: getConnectionManagerTimeout

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
/**
 * Get the connectiion manager timeout value.
 * This is defined by the parameter {@code ClientPNames.CONN_MANAGER_TIMEOUT}.
 * Failing that it uses the parameter {@code CoreConnectionPNames.CONNECTION_TIMEOUT}
 * which defaults to 0 if not defined.
 *
 * @since 4.2
 * @return the timeout value
 */
public static long getConnectionManagerTimeout(final HttpParams params) {
    if (params == null) {
        throw new IllegalArgumentException("HTTP parameters may not be null");
    }
    Long timeout = (Long) params.getParameter(ClientPNames.CONN_MANAGER_TIMEOUT);
    if (timeout != null) {
        return timeout.longValue();
    }
    return HttpConnectionParams.getConnectionTimeout(params);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:HttpClientParams.java

示例6: connectSocket

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
/**
 * @since 4.1
 */
public Socket connectSocket(
        final Socket socket,
        final InetSocketAddress remoteAddress,
        final InetSocketAddress localAddress,
        final HttpParams params) throws IOException, ConnectTimeoutException {
    if (remoteAddress == null) {
        throw new IllegalArgumentException("Remote address may not be null");
    }
    if (params == null) {
        throw new IllegalArgumentException("HTTP parameters may not be null");
    }
    Socket sock = socket;
    if (sock == null) {
        sock = createSocket();
    }
    if (localAddress != null) {
        sock.setReuseAddress(HttpConnectionParams.getSoReuseaddr(params));
        sock.bind(localAddress);
    }
    int connTimeout = HttpConnectionParams.getConnectionTimeout(params);
    int soTimeout = HttpConnectionParams.getSoTimeout(params);

    try {
        sock.setSoTimeout(soTimeout);
        sock.connect(remoteAddress, connTimeout);
    } catch (SocketTimeoutException ex) {
        throw new ConnectTimeoutException("Connect to " + remoteAddress + " timed out");
    }
    return sock;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:PlainSocketFactory.java

示例7: connectSocket

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
public Socket connectSocket(Socket sock,
        InetSocketAddress remoteAddress,
        InetSocketAddress localAddress, HttpParams params)
        throws IOException, UnknownHostException,
        ConnectTimeoutException {
    int connTimeout = HttpConnectionParams.getConnectionTimeout(params);
    int soTimeout = HttpConnectionParams.getSoTimeout(params);

    SSLSocket sslsock = (SSLSocket) ((sock != null) ? sock : createSocket(params));
    if (localAddress != null) sslsock.bind(localAddress);

    sslsock.connect(remoteAddress, connTimeout);
    sslsock.setSoTimeout(soTimeout);
    return sslsock;
}
 
开发者ID:sinacloud,项目名称:sinacloud-sdk-java,代码行数:16,代码来源:HttpClientFactory.java

示例8: connectSocket

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
/**
 * @since 4.1
 */
@Override
public Socket connectSocket(
        final Socket socket,
        final InetSocketAddress remoteAddress,
        final InetSocketAddress localAddress,
        final HttpParams params) throws IOException, ConnectTimeoutException {
    Args.notNull(remoteAddress, "Remote address");
    Args.notNull(params, "HTTP parameters");
    Socket sock = socket;
    if (sock == null) {
        sock = createSocket();
    }
    if (localAddress != null) {
        sock.setReuseAddress(HttpConnectionParams.getSoReuseaddr(params));
        sock.bind(localAddress);
    }
    final int connTimeout = HttpConnectionParams.getConnectionTimeout(params);
    final int soTimeout = HttpConnectionParams.getSoTimeout(params);

    try {
        sock.setSoTimeout(soTimeout);
        sock.connect(remoteAddress, connTimeout);
    } catch (final SocketTimeoutException ex) {
        throw new ConnectTimeoutException("Connect to " + remoteAddress + " timed out");
    }
    return sock;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:31,代码来源:PlainSocketFactory.java

示例9: connectSocket

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
/**
 * @since 4.1
 */
public Socket connectSocket(final Socket sock, final InetSocketAddress remoteAddress, final InetSocketAddress localAddress, final HttpParams params) throws IOException
{
	if (remoteAddress == null)
	{
		throw new IllegalArgumentException("Remote address may not be null");
	}

	if (params == null)
	{
		throw new IllegalArgumentException("HTTP parameters may not be null");
	}

	SSLSocket sslSocket = (SSLSocket) (sock != null ? sock : createSocket());

	if (localAddress != null)
	{
		//            sslSocket.setReuseAddress(HttpConnectionParams.getSoReuseaddr(params));
		sslSocket.bind(localAddress);
	}

	int connTimeout = HttpConnectionParams.getConnectionTimeout(params);
	int soTimeout = HttpConnectionParams.getSoTimeout(params);

	try
	{
		sslSocket.connect(remoteAddress, connTimeout);
	}
	catch (SocketTimeoutException ex)
	{
		throw new ConnectTimeoutException(String.format("Connect to %s/%s timed out", remoteAddress.getHostName(), remoteAddress.getAddress()));
	}

	sslSocket.setSoTimeout(soTimeout);

	if (this.hostnameVerifier != null)
	{
		try
		{
			this.hostnameVerifier.verify(remoteAddress.getHostName(), sslSocket);
			// verifyHostName() didn't blowup - good!
		}
		catch (IOException iox)
		{
			// close the socket before re-throwing the exception
			try
			{
				sslSocket.close();
			}
			catch (Exception x)
			{ /*ignore*/ }
			throw iox;
		}
	}

	return sslSocket;
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:60,代码来源:SSLSocketFactory.java

示例10: connectSocket

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
@Override
public Socket connectSocket(Socket sock, String host, int port, InetAddress localAddress,
		int localPort, HttpParams params) throws IOException, UnknownHostException,
		ConnectTimeoutException {
	if (host == null) {
		throw new IllegalArgumentException("Target host may not be null.");
	}
	if (params == null) {
		throw new IllegalArgumentException("Parameters may not be null.");
	}

	SSLSocket sslsock = (SSLSocket) ((sock != null) ? sock : createSocket());

	if ((localAddress != null) || (localPort > 0)) {
		if (localPort < 0)
			localPort = 0;

		InetSocketAddress isa = new InetSocketAddress(localAddress, localPort);
		sslsock.bind(isa);
	}

	int connTimeout = HttpConnectionParams.getConnectionTimeout(params);
	int soTimeout = HttpConnectionParams.getSoTimeout(params);

	InetSocketAddress remoteAddress = new InetSocketAddress(host, port);

	sslsock.connect(remoteAddress, connTimeout);

	sslsock.setSoTimeout(soTimeout);
	try {
		hostnameVerifier.verify(host, sslsock);
	} catch (IOException iox) {
		try {
			sslsock.close();
		} catch (Exception x) {
		}

		throw iox;
	}

	return sslsock;
}
 
开发者ID:CactusSoft,项目名称:zabbkit-android,代码行数:43,代码来源:MySSLSocketFactory.java

示例11: connectSocket

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
/**
 * @param sock
 *            will be ignored; can be null
 */
@Override
public Socket connectSocket(final Socket sock, 
                            final String host, 
                            final int port,
                            final InetAddress localAddress, 
                            int localPort, 
                            final HttpParams params)
		throws IOException
{

	if (host == null)
	{
		throw new IllegalArgumentException("Target host may not be null.");
	}
	if (params == null)
	{
		throw new IllegalArgumentException("Parameters may not be null.");
	}

	TcpipNetAddress localNetAddress = null;
	if (localAddress != null || localPort > 0)
	{
		// we need to bind explicitly
		if (localPort < 0)
		{
			localPort = 0; // indicates "any"
		}

		localNetAddress = new TcpipNetAddress(localAddress, localPort);
	}

	final int timeoutInMs = HttpConnectionParams
			.getConnectionTimeout(params);

	// open connection without explicit DNS resolution
	final Map<String, Object> localProperties = new HashMap<String, Object>();
	localProperties.put(TcpipNetLayer.TIMEOUT_IN_MS, Integer.valueOf(timeoutInMs));
	final TcpipNetAddress remoteNetAddress = new TcpipNetAddress(host, port);

	try
	{
		final NetSocket netSocket = lowerNetLayer.createNetSocket(
				localProperties, localNetAddress, remoteNetAddress);
		if (sock != null && sock instanceof NetSocket2Socket)
		{
			// change NetSocket of exiting wrapper
			final NetSocket2Socket netSocket2Socket = (NetSocket2Socket) sock;
			netSocket2Socket.setNetSocket(netSocket);
			return netSocket2Socket;
		}
		else
		{
			// create new wrapper
			return new NetSocket2Socket(netSocket);
		}

	}
	catch (final SocketTimeoutException ex)
	{
		throw new ConnectTimeoutException("Connect to " + remoteNetAddress
				+ " timed out");
	}
}
 
开发者ID:B4dT0bi,项目名称:silvertunnel-ng,代码行数:68,代码来源:NetlibSocketFactory.java

示例12: getConnectionManagerTimeout

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
/**
 * Get the connectiion manager timeout value.
 * This is defined by the parameter {@code ClientPNames.CONN_MANAGER_TIMEOUT}.
 * Failing that it uses the parameter {@code CoreConnectionPNames.CONNECTION_TIMEOUT}
 * which defaults to 0 if not defined.
 *
 * @since 4.2
 * @return the timeout value
 */
public static long getConnectionManagerTimeout(final HttpParams params) {
    Args.notNull(params, "HTTP parameters");
    final Long timeout = (Long) params.getParameter(ClientPNames.CONN_MANAGER_TIMEOUT);
    if (timeout != null) {
        return timeout.longValue();
    }
    return HttpConnectionParams.getConnectionTimeout(params);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:18,代码来源:HttpClientParams.java


注:本文中的org.apache.http.params.HttpConnectionParams.getConnectionTimeout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。