Example usage for org.apache.commons.httpclient.params HttpConnectionParams getSendBufferSize

List of usage examples for org.apache.commons.httpclient.params HttpConnectionParams getSendBufferSize

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.params HttpConnectionParams getSendBufferSize.

Prototype

public int getSendBufferSize() 

Source Link

Usage

From source file:at.gv.egovernment.moa.id.auth.validator.parep.client.szrgw.SZRGWSecureSocketFactory.java

/**
 * @see SecureProtocolSocketFactory#createSocket(java.lang.String,int,java.net.InetAddress,int,org.apache.commons.httpclient.params.HttpConnectionParams)
 *///from  ww  w  .  jav a 2s .  co m
public Socket createSocket(String host, int port, InetAddress clientHost, int clientPort,
        HttpConnectionParams params)
        throws IOException, UnknownHostException, org.apache.commons.httpclient.ConnectTimeoutException {

    Socket socket = createSocket(host, port, clientHost, clientPort);
    if (socket != null) {
        // socket.setKeepAlive(false);
        if (params.getReceiveBufferSize() >= 0)
            socket.setReceiveBufferSize(params.getReceiveBufferSize());
        if (params.getSendBufferSize() >= 0)
            socket.setSendBufferSize(params.getSendBufferSize());
        socket.setReuseAddress(true);
        if (params.getSoTimeout() >= 0)
            socket.setSoTimeout(params.getSoTimeout());
    }
    return socket;

}

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");
    }//ww  w .j a  v a 2 s  .c  o m

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