Java Socket setSendBufferSize () methodThe 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 1Test it NowOutput: Send Buffer size: 67 Example 2Test it NowOutput: Exception in thread "main" java.lang.IllegalArgumentException: negative send size at java.net.Socket.setSendBufferSize(Socket.java:1193) at com.javaTpoint.JavaSocketSetSendBufferSizeExample2.main( JavaSocketSetSendBufferSizeExample2.java:11) Example 3Test it NowOutput: Exception in thread "main" java.net.SocketException: Socket is closed at java.net.Socket.setSendBufferSize(Socket.java:1196) at com.javaTpoint.JavaSocketSetSendBufferSizeExample2.main( JavaSocketSetSendBufferSizeExample2.java:13) Next TopicJava Socket Class |
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