Online Java Compiler By
JavaTpoint.com
import java.io.IOException; import java.net.*; public class JavaSocketGetReceiveBufferSizeExample3 { public static void main(String[] args) throws IOException { //calling the constructor of the socket class Socket socket = new Socket(); //setting the buffer size with the help of setReceiveBufferSize() method //the buffer size should be greater than 0, else it will throw an exception socket.setReceiveBufferSize(0); //getReceiveBufferSize() method returns the buffer size for this socket System.out.println("Buffer size: "+socket.getReceiveBufferSize()); } }
Output