1 package org.apache.tomcat.util.net; 2 3 import java.net.Socket ; 4 import java.net.SocketException ; 5 6 public class SocketProperties { 7 11 protected boolean directBuffer = true; 12 16 protected int rxBufSize = 25188; 17 21 protected int txBufSize = 43800; 22 23 29 protected int bufferPool = 500; 30 31 32 37 protected int bufferPoolSize = 1024*1024*100; 38 39 42 protected boolean tcpNoDelay = false; 43 46 protected boolean soKeepAlive = false; 47 50 protected boolean ooBInline = true; 51 54 protected boolean soReuseAddress = true; 55 58 protected boolean soLingerOn = true; 59 62 protected int soLingerTime = 25; 63 66 protected int soTimeout = 5000; 67 75 protected int soTrafficClass = 0x04 | 0x08 | 0x010; 76 81 protected int performanceConnectionTime = 1; 82 87 protected int performanceLatency = 0; 88 93 protected int performanceBandwidth = 1; 94 95 96 public void setProperties(Socket socket) throws SocketException { 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 |