public class DatagramSocketBufferControl extends Object
DatagramSockets.| Modifier and Type | Method and Description |
|---|---|
static int |
getReceiveBufferSize(DatagramSocket d)
Get value of the SO_RCVBUF option for this socket, that is the
buffer size used by the platform for input on the this Socket.
|
static void |
setReceiveBufferSize(DatagramSocket d,
int size)
Sets the SO_RCVBUF option to the specified value for this
DatagramSocket.
|
public static void setReceiveBufferSize(DatagramSocket d, int size) throws SocketException
Increasing buffer size can increase the performance of network I/O for high-volume connection, while decreasing it can help reduce the backlog of incoming data. For UDP, this sets the buffer size for received packets.
Because SO_RCVBUF is a hint, applications that want to verify what size the buffers were set to should call getReceiveBufferSize. This method shall throw IllegalArgumentException - if size is 0 or is negative.
d - The DatagramSocket for which to change the receive buffer
size.size - The requested size of the receive buffer, in bytes.SocketException - - If there is an error when setting the
SO_RCVBUF option.public static int getReceiveBufferSize(DatagramSocket d) throws SocketException
d - The DatagramSocket for which to query the receive buffer
size.SocketException - - If there is an error when querying the
SO_RCVBUF option.Copyright © 2012 code4tv.com. All Rights Reserved.