Details
Description
Socket.setReceiveBufferSize() must be called before bind() on a ServerSocket in order to allow TCP receive window scaling up to the configured buffer size (http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html#setReceiveBufferSize(int)). Currently, socket options are set after bind() is called. This results in the correct Java receive buffer size, but does not allow the TCP stack to scale receive windows above 64k. Severe performance degradation can occur on high-latency high-bandwidth connections.
The following patch is a possible solution to this issue, though there may be a cleaner way to implement a fix within the framework.
Best regards,
Greg
Index: core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java
===================================================================
— core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java (revision 642333)
+++ core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java (working copy)
@@ -163,6 +163,16 @@
try {
ch = SocketChannel.open();
ch.socket().setReuseAddress(true);
+
+ // Receive buffer size must be set BEFORE the socket is connected
+ // in order for the TCP window to be sized accordingly
+ if (config instanceof SocketConnectorConfig)
+
if (localAddress != null)