DatagramSocket SetReceiveBufferSize() Example

Sets the SO_RCVBUF option to the specified value for this DatagramSocket.


DatagramSocketclass SetReceiveBufferSize() method example. This example shows you how to use SetReceiveBufferSize() method.This method Sets the SO_RCVBUF option to the specified value for this DatagramSocket.

Here is the code:-

/**
 * @Program that Sets the SO_RCVBUF option to the specified value for this DatagramSocket.
 * GetReceiveBufferSize.java 
 * Author:-RoseIndia Team
 * Date:-20-jun-2008
 */
import java.net.*;

public class SetReceiveBufferSize {

    public static void main(String[] argsthrows Exception {
        DatagramSocket ds = new DatagramSocket();
        ds.connect(new InetSocketAddress(9090));
        //Get value of the SO_RCVBUF option for this DatagramSocket
        int i = ds.getReceiveBufferSize();
        System.out.println("RCVBUF for this DatagramSocket is: " + i);
        ds.setReceiveBufferSize(234);
         int j = ds.getReceiveBufferSize();
        System.out.println("RCVBUF for this DatagramSocket is: " + j);
    }
}

Output of the program:-
 RCVBUF for this DatagramSocket is: 55296
RCVBUF for this DatagramSocket is: 1024

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US