Online Java Compiler By
JavaTpoint.com
import java.io.IOException; import java.net.*; public class JavaSocketSetSendBufferSizeExample3 { public static void main(String[] args) throws IOException { //calling the constructor of the socket class Socket socket = new Socket(); //closing the socket socket.close(); //setSendBufferSize() sets the send buffer size or SO_SNDBUF option with the specified value //it will throw an exception, else the socket is already closed. socket.setSendBufferSize(67); //getSendBufferSize() method returns the buffer size(SO_SNDBUF) used by the platform for output System.out.println("Send Buffer size: "+socket.getSendBufferSize()); } }
Output