KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tomcat > util > net > SocketProperties


1 package org.apache.tomcat.util.net;
2
3 import java.net.Socket JavaDoc;
4 import java.net.SocketException JavaDoc;
5
6 public class SocketProperties {
7     /**
8      * Enable/disable direct buffers for the network buffers
9      * Default value is enabled
10      */

11     protected boolean directBuffer = true;
12     /**
13      * Socket receive buffer size in bytes (SO_RCVBUF)
14      * Default value is 25188
15      */

16     protected int rxBufSize = 25188;
17     /**
18      * Socket send buffer size in bytes (SO_SNDBUF)
19      * Default value is 43800
20      */

21     protected int txBufSize = 43800;
22     
23     /**
24      * NioChannel pool size for the endpoint,
25      * this value is how many channels
26      * -1 means unlimited cached, 0 means no cache
27      * Default value is 500
28      */

29     protected int bufferPool = 500;
30     
31
32     /**
33      * Buffer pool size in bytes to be cached
34      * -1 means unlimited, 0 means no cache
35      * Default value is 100MB (1024*1024*100 bytes)
36      */

37     protected int bufferPoolSize = 1024*1024*100;
38     
39     /**
40      * TCP_NO_DELAY option, default is false
41      */

42     protected boolean tcpNoDelay = false;
43     /**
44      * SO_KEEPALIVE option, default is false
45      */

46     protected boolean soKeepAlive = false;
47     /**
48      * OOBINLINE option, default is true
49      */

50     protected boolean ooBInline = true;
51     /**
52      * SO_REUSEADDR option, default is true
53      */

54     protected boolean soReuseAddress = true;
55     /**
56      * SO_LINGER option, default is true, paired with the <code>soLingerTime</code> value
57      */

58     protected boolean soLingerOn = true;
59     /**
60      * SO_LINGER option, default is 25 seconds.
61      */

62     protected int soLingerTime = 25;
63     /**
64      * SO_TIMEOUT option, default is 5000 milliseconds
65      */

66     protected int soTimeout = 5000;
67     /**
68      * Traffic class option, value between 0 and 255
69      * IPTOS_LOWCOST (0x02)
70      * IPTOS_RELIABILITY (0x04)
71      * IPTOS_THROUGHPUT (0x08)
72      * IPTOS_LOWDELAY (0x10)
73      * Default value is 0x04 | 0x08 | 0x010
74      */

75     protected int soTrafficClass = 0x04 | 0x08 | 0x010;
76     /**
77      * Performance preferences according to
78      * http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html#setPerformancePreferences(int,%20int,%20int)
79      * Default value is 1
80      */

81     protected int performanceConnectionTime = 1;
82     /**
83      * Performance preferences according to
84      * http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html#setPerformancePreferences(int,%20int,%20int)
85      * Default value is 0
86      */

87     protected int performanceLatency = 0;
88     /**
89      * Performance preferences according to
90      * http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html#setPerformancePreferences(int,%20int,%20int)
91      * Default value is 1
92      */

93     protected int performanceBandwidth = 1;
94     
95
96     public void setProperties(Socket JavaDoc socket) throws SocketException JavaDoc{
97         socket.setReceiveBufferSize(rxBufSize);
98         socket.setSendBufferSize(txBufSize);
99         socket.setOOBInline(ooBInline);
100         socket.setKeepAlive(soKeepAlive);
101         socket.setPerformancePreferences(performanceConnectionTime,performanceLatency,performanceBandwidth);
102         socket.setReuseAddress(soReuseAddress);
103         socket.setSoLinger(soLingerOn,soLingerTime);
104         socket.setSoTimeout(soTimeout);
105         socket.setTcpNoDelay(tcpNoDelay);
106         socket.setTrafficClass(soTrafficClass);
107     }
108
109     public boolean getDirectBuffer() {
110         return directBuffer;
111     }
112
113     public boolean getOoBInline() {
114         return ooBInline;
115     }
116
117     public int getPerformanceBandwidth() {
118         return performanceBandwidth;
119     }
120
121     public int getPerformanceConnectionTime() {
122         return performanceConnectionTime;
123     }
124
125     public int getPerformanceLatency() {
126         return performanceLatency;
127     }
128
129     public int getRxBufSize() {
130         return rxBufSize;
131     }
132
133     public boolean getSoKeepAlive() {
134         return soKeepAlive;
135     }
136
137     public boolean getSoLingerOn() {
138         return soLingerOn;
139     }
140
141     public int getSoLingerTime() {
142         return soLingerTime;
143     }
144
145     public boolean getSoReuseAddress() {
146         return soReuseAddress;
147     }
148
149     public int getSoTimeout() {
150         return soTimeout;
151     }
152
153     public int getSoTrafficClass() {
154         return soTrafficClass;
155     }
156
157     public boolean getTcpNoDelay() {
158         return tcpNoDelay;
159     }
160
161     public int getTxBufSize() {
162         return txBufSize;
163     }
164
165     public int getBufferPool() {
166         return bufferPool;
167     }
168
169     public int getBufferPoolSize() {
170         return bufferPoolSize;
171     }
172
173     public int getDirectBufferPool() {
174         return bufferPool;
175     }
176
177     public void setPerformanceConnectionTime(int performanceConnectionTime) {
178         this.performanceConnectionTime = performanceConnectionTime;
179     }
180
181     public void setTxBufSize(int txBufSize) {
182         this.txBufSize = txBufSize;
183     }
184
185     public void setTcpNoDelay(boolean tcpNoDelay) {
186         this.tcpNoDelay = tcpNoDelay;
187     }
188
189     public void setSoTrafficClass(int soTrafficClass) {
190         this.soTrafficClass = soTrafficClass;
191     }
192
193     public void setSoTimeout(int soTimeout) {
194         this.soTimeout = soTimeout;
195     }
196
197     public void setSoReuseAddress(boolean soReuseAddress) {
198         this.soReuseAddress = soReuseAddress;
199     }
200
201     public void setSoLingerTime(int soLingerTime) {
202         this.soLingerTime = soLingerTime;
203     }
204
205     public void setSoKeepAlive(boolean soKeepAlive) {
206         this.soKeepAlive = soKeepAlive;
207     }
208
209     public void setRxBufSize(int rxBufSize) {
210         this.rxBufSize = rxBufSize;
211     }
212
213     public void setPerformanceLatency(int performanceLatency) {
214         this.performanceLatency = performanceLatency;
215     }
216
217     public void setPerformanceBandwidth(int performanceBandwidth) {
218         this.performanceBandwidth = performanceBandwidth;
219     }
220
221     public void setOoBInline(boolean ooBInline) {
222         this.ooBInline = ooBInline;
223     }
224
225     public void setDirectBuffer(boolean directBuffer) {
226         this.directBuffer = directBuffer;
227     }
228
229     public void setSoLingerOn(boolean soLingerOn) {
230         this.soLingerOn = soLingerOn;
231     }
232
233     public void setBufferPool(int bufferPool) {
234         this.bufferPool = bufferPool;
235     }
236
237     public void setBufferPoolSize(int bufferPoolSize) {
238         this.bufferPoolSize = bufferPoolSize;
239     }
240
241     public void setDirectBufferPool(int directBufferPool) {
242         this.bufferPool = directBufferPool;
243     }
244
245 }
Popular Tags