org.dvb.net
Class DatagramSocketBufferControl

java.lang.Object
  extended by org.dvb.net.DatagramSocketBufferControl

public class DatagramSocketBufferControl
extends java.lang.Object

This class provides additional control over buffering for DatagramSockets.


Method Summary
static int getReceiveBufferSize(java.net.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(java.net.DatagramSocket d, int size)
          Sets the SO_RCVBUF option to the specified value for this DatagramSocket.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setReceiveBufferSize

public static void setReceiveBufferSize(java.net.DatagramSocket d,
                                        int size)
                                 throws java.net.SocketException
Sets the SO_RCVBUF option to the specified value for this DatagramSocket. The SO_RCVBUF option is used by the platform's networking code as a hint for the size to use when allocating the underlying network I/O buffers.

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.

Parameters:
d - The DatagramSocket for which to change the receive buffer size.
size - The requested size of the receive buffer, in bytes.
Throws:
java.net.SocketException - - If there is an error when setting the SO_RCVBUF option.

getReceiveBufferSize

public static int getReceiveBufferSize(java.net.DatagramSocket d)
                                throws java.net.SocketException
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. The value returned need not be the value previously set by setReceiveBufferSize (if any).

Parameters:
d - The DatagramSocket for which to query the receive buffer size.
Returns:
The size of the receive buffer, in bytes.
Throws:
java.net.SocketException - - If there is an error when querying the SO_RCVBUF option.