How do I set the socket input and output buffer sizes in Java?
You cannot set the socket input and output buffer sizes in Java versions prior to 1.2. To do so requires writing native code. You just have to live with whatever the system default values are.Starting with Java 1.2, java.net.Socket has acquired four new methods:
void setSendBufferSize(int size)
void setReceiveBufferSize(int size)
You can now use these to set and fetch the socket send and receive buffer sizes. When setting the buffer sizes, it helps to remember that the value is only a hint to the underlying system TCP/IP code as to what size should be allocated. The underlying system will not necessarily allocate exactly what you request.