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

The following are Jave code examples for showing how to use getReceiveBufferSize() 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: SocketInputBuffer.java   Source Code and License Vote up 6 votes
/**
 * Creates an instance of this class.
 *
 * @param socket the socket to read data from.
 * @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#getReceiveBufferSize()}. If resultant number is less
 *   than <code>1024</code> it is set to <code>1024</code>.
 * @param params HTTP parameters.
 */
public SocketInputBuffer(
        final Socket socket,
        int buffersize,
        final HttpParams params) throws IOException {
    super();
    if (socket == null) {
        throw new IllegalArgumentException("Socket may not be null");
    }
    this.socket = socket;
    this.eof = false;
    if (buffersize < 0) {
        buffersize = socket.getReceiveBufferSize();
    }
    if (buffersize < 1024) {
        buffersize = 1024;
    }
    init(socket.getInputStream(), buffersize, params);
}
 
Example 2
Project: FirefoxData-android   File: SocketInputBuffer.java   Source Code and License Vote up 6 votes
/**
 * Creates an instance of this class.
 *
 * @param socket the socket to read data from.
 * @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#getReceiveBufferSize()}. If resultant number is less
 *   than <code>1024</code> it is set to <code>1024</code>.
 * @param params HTTP parameters.
 */
public SocketInputBuffer(
        final Socket socket,
        final int buffersize,
        final HttpParams params) throws IOException {
    super();
    Args.notNull(socket, "Socket");
    this.socket = socket;
    this.eof = false;
    int n = buffersize;
    if (n < 0) {
        n = socket.getReceiveBufferSize();
    }
    if (n < 1024) {
        n = 1024;
    }
    init(socket.getInputStream(), n, params);
}
 
Example 3
Project: tomcat7   File: ObjectReader.java   Source Code and License Vote up 5 votes
/**
 * Creates an <code>ObjectReader</code> for a TCP socket
 * @param socket Socket
 */
public ObjectReader(Socket socket) {
    try{
        this.buffer = new XByteBuffer(socket.getReceiveBufferSize(), true);
    }catch ( IOException x ) {
        //unable to get buffer size
        log.warn("Unable to retrieve the socket receiver buffer size, setting to default 43800 bytes.");
        this.buffer = new XByteBuffer(43800,true);
    }
}
 
Example 4
Project: apache-tomcat-7.0.73-with-comment   File: ObjectReader.java   Source Code and License Vote up 5 votes
/**
 * Creates an <code>ObjectReader</code> for a TCP socket
 * @param socket Socket
 */
public ObjectReader(Socket socket) {
    try{
        this.buffer = new XByteBuffer(socket.getReceiveBufferSize(), true);
    }catch ( IOException x ) {
        //unable to get buffer size
        log.warn("Unable to retrieve the socket receiver buffer size, setting to default 43800 bytes.");
        this.buffer = new XByteBuffer(43800,true);
    }
}
 
Example 5
Project: lazycat   File: ObjectReader.java   Source Code and License Vote up 5 votes
/**
 * Creates an <code>ObjectReader</code> for a TCP socket
 * 
 * @param socket
 *            Socket
 */
public ObjectReader(Socket socket) {
	try {
		this.buffer = new XByteBuffer(socket.getReceiveBufferSize(), true);
	} catch (IOException x) {
		// unable to get buffer size
		log.warn("Unable to retrieve the socket receiver buffer size, setting to default 43800 bytes.");
		this.buffer = new XByteBuffer(43800, true);
	}
}