corba/src/share/classes/com/sun/corba/se/impl/transport/DefaultSocketFactoryImpl.java
Print this page
@@ -30,10 +30,11 @@
import java.net.Socket;
import java.net.SocketException;
import java.net.ServerSocket;
import java.nio.channels.SocketChannel;
import java.nio.channels.ServerSocketChannel;
+import java.security.PrivilegedAction;
import com.sun.corba.se.pept.transport.Acceptor;
import com.sun.corba.se.spi.orb.ORB;
import com.sun.corba.se.spi.transport.ORBSocketFactory;
@@ -42,11 +43,27 @@
public class DefaultSocketFactoryImpl
implements ORBSocketFactory
{
private ORB orb;
+ private static boolean keepAlive = false;
+ static {
+ java.security.AccessController.doPrivileged(
+ new PrivilegedAction<Void>() {
+ @Override
+ public Void run () {
+ String value =
+ System.getProperty("com.sun.CORBA.transport.enableTcpKeepAlive");
+ if (value != null)
+ keepAlive = !"false".equalsIgnoreCase(value);
+
+ return null;
+ }
+ });
+ }
+
public void setORB(ORB orb)
{
this.orb = orb;
}
@@ -83,10 +100,13 @@
}
// Disable Nagle's algorithm (i.e., always send immediately).
socket.setTcpNoDelay(true);
+ if (keepAlive)
+ socket.setKeepAlive(true);
+
return socket;
}
public void setAcceptedSocketOptions(Acceptor acceptor,
ServerSocket serverSocket,
@@ -93,9 +113,11 @@
Socket socket)
throws SocketException
{
// Disable Nagle's algorithm (i.e., always send immediately).
socket.setTcpNoDelay(true);
+ if (keepAlive)
+ socket.setKeepAlive(true);
}
}
// End of file.