本文整理汇总了Java中java.net.Socket.getReceiveBufferSize方法的典型用法代码示例。如果您正苦于以下问题:Java Socket.getReceiveBufferSize方法的具体用法?Java Socket.getReceiveBufferSize怎么用?Java Socket.getReceiveBufferSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.net.Socket
的用法示例。
在下文中一共展示了Socket.getReceiveBufferSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SocketInputBuffer
import java.net.Socket; //导入方法依赖的package包/类
/**
* 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);
}
示例2: SocketInputBuffer
import java.net.Socket; //导入方法依赖的package包/类
/**
* 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);
}
示例3: ObjectReader
import java.net.Socket; //导入方法依赖的package包/类
/**
* 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);
}
}
示例4: ObjectReader
import java.net.Socket; //导入方法依赖的package包/类
/**
* 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);
}
}