Java Code Examples for java.net.Socket.getSendBufferSize()

The following are Jave code examples for showing how to use getSendBufferSize() of the java.net.Socket class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: lams   File: SocketOutputBuffer.java   Source Code and License Vote up 6 votes
/**
 * Creates an instance of this class.
 *
 * @param socket the socket to write data to.
 * @param buffersize the size of the internal buffer. If this number is less
 *   than <code>0</code> it is set to the value of
 *   {@link Socket#getSendBufferSize()}. If resultant number is less
 *   than <code>1024</code> it is set to <code>1024</code>.
 * @param params HTTP parameters.
 */
public SocketOutputBuffer(
        final Socket socket,
        int buffersize,
        final HttpParams params) throws IOException {
    super();
    if (socket == null) {
        throw new IllegalArgumentException("Socket may not be null");
    }
    if (buffersize < 0) {
        buffersize = socket.getSendBufferSize();
    }
    if (buffersize < 1024) {
        buffersize = 1024;
    }
    init(socket.getOutputStream(), buffersize, params);
}
 
Example 2
Project: FirefoxData-android   File: SocketOutputBuffer.java   Source Code and License Vote up 6 votes
/**
 * Creates an instance of this class.
 *
 * @param socket the socket to write data to.
 * @param buffersize the size of the internal buffer. If this number is less
 *   than <code>0</code> it is set to the value of
 *   {@link Socket#getSendBufferSize()}. If resultant number is less
 *   than <code>1024</code> it is set to <code>1024</code>.
 * @param params HTTP parameters.
 */
public SocketOutputBuffer(
        final Socket socket,
        final int buffersize,
        final HttpParams params) throws IOException {
    super();
    Args.notNull(socket, "Socket");
    int n = buffersize;
    if (n < 0) {
        n = socket.getSendBufferSize();
    }
    if (n < 1024) {
        n = 1024;
    }
    init(socket.getOutputStream(), n, params);
}