corba/src/share/classes/com/sun/corba/se/impl/transport/DefaultSocketFactoryImpl.java
equal
deleted
inserted
replaced
30 import java.net.Socket; |
30 import java.net.Socket; |
31 import java.net.SocketException; |
31 import java.net.SocketException; |
32 import java.net.ServerSocket; |
32 import java.net.ServerSocket; |
33 import java.nio.channels.SocketChannel; |
33 import java.nio.channels.SocketChannel; |
34 import java.nio.channels.ServerSocketChannel; |
34 import java.nio.channels.ServerSocketChannel; |
|
35 import java.security.PrivilegedAction; |
35 |
36 |
36 import com.sun.corba.se.pept.transport.Acceptor; |
37 import com.sun.corba.se.pept.transport.Acceptor; |
37 |
38 |
38 import com.sun.corba.se.spi.orb.ORB; |
39 import com.sun.corba.se.spi.orb.ORB; |
39 import com.sun.corba.se.spi.transport.ORBSocketFactory; |
40 import com.sun.corba.se.spi.transport.ORBSocketFactory; |
42 |
43 |
43 public class DefaultSocketFactoryImpl |
44 public class DefaultSocketFactoryImpl |
44 implements ORBSocketFactory |
45 implements ORBSocketFactory |
45 { |
46 { |
46 private ORB orb; |
47 private ORB orb; |
|
48 private static final boolean keepAlive; |
|
49 |
|
50 static { |
|
51 keepAlive = java.security.AccessController.doPrivileged( |
|
52 new PrivilegedAction<Boolean>() { |
|
53 @Override |
|
54 public Boolean run () { |
|
55 String value = |
|
56 System.getProperty("com.sun.CORBA.transport.enableTcpKeepAlive"); |
|
57 if (value != null) |
|
58 return new Boolean(!"false".equalsIgnoreCase(value)); |
|
59 |
|
60 return Boolean.FALSE; |
|
61 } |
|
62 }); |
|
63 } |
47 |
64 |
48 public void setORB(ORB orb) |
65 public void setORB(ORB orb) |
49 { |
66 { |
50 this.orb = orb; |
67 this.orb = orb; |
51 } |
68 } |
83 } |
100 } |
84 |
101 |
85 // Disable Nagle's algorithm (i.e., always send immediately). |
102 // Disable Nagle's algorithm (i.e., always send immediately). |
86 socket.setTcpNoDelay(true); |
103 socket.setTcpNoDelay(true); |
87 |
104 |
|
105 if (keepAlive) |
|
106 socket.setKeepAlive(true); |
|
107 |
88 return socket; |
108 return socket; |
89 } |
109 } |
90 |
110 |
91 public void setAcceptedSocketOptions(Acceptor acceptor, |
111 public void setAcceptedSocketOptions(Acceptor acceptor, |
92 ServerSocket serverSocket, |
112 ServerSocket serverSocket, |
93 Socket socket) |
113 Socket socket) |
94 throws SocketException |
114 throws SocketException |
95 { |
115 { |
96 // Disable Nagle's algorithm (i.e., always send immediately). |
116 // Disable Nagle's algorithm (i.e., always send immediately). |
97 socket.setTcpNoDelay(true); |
117 socket.setTcpNoDelay(true); |
|
118 if (keepAlive) |
|
119 socket.setKeepAlive(true); |
98 } |
120 } |
99 } |
121 } |
100 |
122 |
101 // End of file. |
123 // End of file. |