Java Socket getReceiveBufferSize() method25 Mar 2025 | 2 min read The 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 1Output: Buffer size: 789 Example 2Output: Buffer size: 65536 Example 3Output: Exception in thread "main" java.lang.IllegalArgumentException: invalid receive size at java.net.Socket.setReceiveBufferSize(Socket.java:1267) at com.tpointtech.JavaSocketGetReceiveBufferSizeExample3.main(JavaSocketGetReceiveBufferSizeExample3.java:11) Example 4Output: Exception in thread "main" java.net.SocketException: Socket is closed at java.net.Socket.setReceiveBufferSize(Socket.java:1270) at com.tpointtech.JavaSocketGetReceiveBufferSizeExample4.main(JavaSocketGetReceiveBufferSizeExample4.java:12) 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