我知道套接字有 setReceiveBufferSize 方法,但为什么 severSocket 有一个。你知道如果接受一个连接我会得到一个套接字来处理 io 的东西,所以我只关心套接字实例,我可以设置接收缓冲区。那么 serversocket setReceiveBufferSize 做什么工作呢?
public synchronized void setReceiveBufferSize (int size) throws SocketException {
if (!(size > 0)) {
throw new IllegalArgumentException("negative receive size");
}
if (isClosed())
throw new SocketException("Socket is closed");
getImpl().setOption(SocketOptions.SO_RCVBUF, new Integer(size));
}