List of usage examples for org.apache.commons.httpclient.params HttpConnectionParams getLinger
public int getLinger()
From source file:io.hops.hopsworks.api.util.CustomSSLProtocolSocketFactory.java
@Override public Socket createSocket(String host, int port, InetAddress localAddress, int localPort, HttpConnectionParams httpConnectionParams) throws IOException, UnknownHostException, ConnectTimeoutException { if (httpConnectionParams == null) { LOG.log(Level.SEVERE, "Creating SSL socket but HTTP connection parameters is null"); throw new IllegalArgumentException("HTTP connection parameters cannot be null"); }/* w ww .j a v a2 s . com*/ Socket socket = getSslContext().getSocketFactory().createSocket(); SocketAddress localSocketAddress = new InetSocketAddress(localAddress, localPort); SocketAddress remoteSocketAddress = new InetSocketAddress(host, port); socket.setSoTimeout(httpConnectionParams.getSoTimeout()); if (httpConnectionParams.getLinger() > 0) { socket.setSoLinger(true, httpConnectionParams.getLinger()); } else { socket.setSoLinger(false, 0); } socket.setTcpNoDelay(httpConnectionParams.getTcpNoDelay()); if (httpConnectionParams.getSendBufferSize() >= 0) { socket.setSendBufferSize(httpConnectionParams.getSendBufferSize()); } if (httpConnectionParams.getReceiveBufferSize() >= 0) { socket.setReceiveBufferSize(httpConnectionParams.getReceiveBufferSize()); } socket.bind(localSocketAddress); socket.connect(remoteSocketAddress, httpConnectionParams.getConnectionTimeout()); return socket; }