DatagramSocket SetSendBufferSize() Example
Sets the SO_SNDBUF option to the specified value for this DatagramSocket.
DatagramSocketclass SetSendBufferSize() method example. This example shows you how to use SetSendBufferSize() method.This method Sets the SO_SNDBUF option to the specified value for this DatagramSocket.
Here is the code:-
/**
* @Program that Sets the SO_SNDBUF option to the specified value for this DatagramSocket.
* SetSendBufferSize.java
* Author:-RoseIndia Team
* Date:-20-jun-2008
*/
import java.net.*;
public class SetSendBufferSize {
public static void main(String[] args) throws Exception {
DatagramSocket ds = new DatagramSocket();
ds.connect(new InetSocketAddress(9090));
System.out.println("SNDBUF option for this DatagramSocket is: " + ds.getSendBufferSize());
//Sets the SO_SNDBUF option to the specified value for this DatagramSocket.
ds.setSendBufferSize(2048);
System.out.println("SNDBUF option for this DatagramSocket is: " + ds.getSendBufferSize());
}
} |
Output of the program:-
SNDBUF option for this DatagramSocket is: 55296
SNDBUF option for this DatagramSocket is: 2048 |
|