Java Socket getReceiveBufferSize() methodThe getReceiveBufferSize() method of Java Socket class returns the buffer size (SO_RCVBUF option) for this socket. SyntaxParameterNA ReturnsThe getReceiveBufferSize() method returns the buffer size or the SO_RCVBUF option for this socket. ThrowsSocketException - if there is an error in the underlying protocol, such as a TCP error. Example 1Test it NowOutput: Buffer size: 789 Example 2Test it NowOutput: Buffer size: 65536 Example 3Test it NowOutput: Exception in thread "main" java.lang.IllegalArgumentException: invalid receive size at java.net.Socket.setReceiveBufferSize(Socket.java:1267) at com.javaTpoint.JavaSocketGetReceiveBufferSizeExample3.main(JavaSocketGetReceiveBufferSizeExample3.java:11) Example 4Test it NowOutput: Exception in thread "main" java.net.SocketException: Socket is closed at java.net.Socket.setReceiveBufferSize(Socket.java:1270) at com.javaTpoint.JavaSocketGetReceiveBufferSizeExample4.main(JavaSocketGetReceiveBufferSizeExample4.java:12) 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