Java Socket setSendBufferSize () method25 Mar 2025 | 2 min read The setSendBufferSize () method of Java Socket class sets the SO_SNDBUF option to the given value for this socket. The size value should be greater than 0. SyntaxParameterThe parameter 'size' represents the size to which the send buffer size is set. ReturnNA ThrowsIllegalArgumentException - if the size is 0 or less than zero. SocketException - if an error is there in the underlying protocol, such as a TCP error. Example 1Output: Send Buffer size: 67 Example 2Output: Exception in thread "main" java.lang.IllegalArgumentException: negative send size at java.net.Socket.setSendBufferSize(Socket.java:1193) at com.tpointtech.JavaSocketSetSendBufferSizeExample2.main( JavaSocketSetSendBufferSizeExample2.java:11) Example 3Output: Exception in thread "main" java.net.SocketException: Socket is closed at java.net.Socket.setSendBufferSize(Socket.java:1196) at com.tpointtech.JavaSocketSetSendBufferSizeExample2.main( JavaSocketSetSendBufferSizeExample2.java:13) Next TopicJava Socket Class |
We request you to subscribe our newsletter for upcoming updates.

We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India