Online Java Compiler By
JavaTpoint.com
import java.io.IOException; import java.net.*; public class JavaSocketGetReceiveBufferSizeExample4 { public static void main(String[] args) throws IOException { //calling the constructor of the socket class Socket socket = new Socket(); //closing the socket socket.close(); //setting the buffer size with the help of setReceiveBufferSize() method socket.setReceiveBufferSize(10); //it will throw an error as the socket is already closed //getReceiveBufferSize() method returns the buffer size set for this socket System.out.println("Buffer size: "+socket.getReceiveBufferSize()); } }
Output