Java Socket getSendBufferSize() method

The getSendBufferSize () method of Java Socket class returns the buffer size(SO_SNDBUF) used by the platform for output on this socket.

Syntax

Parameter

NA

Return

The getSendBufferSize () method returns the value of the SO_SNDBUF option of the specified Socket.

Throws

SocketException - if an error is there in the protocol, such as a TCP error.

Example 1

Test it Now

Output:

Send Buffer size: 67

Example 2

Test it Now

Output:

Send Buffer size: 65536

Example 3

Test it Now

Output:

Exception in thread "main" java.lang.IllegalArgumentException: negative send size
	at java.net.Socket.setSendBufferSize(Socket.java:1193)
	at com.javaTpoint.JavaSocketGetSendBufferSizeExample3.main(JavaSocketGetSendBufferSizeExample3.java:11)




Latest Courses