1 22 package org.jboss.net.sockets; 23 24 import java.net.Socket ; 25 import java.net.InetAddress ; 26 import java.net.SocketAddress ; 27 import java.net.SocketException ; 28 import java.io.InputStream ; 29 import java.io.IOException ; 30 import java.io.OutputStream ; 31 import java.nio.channels.SocketChannel ; 32 33 38 public class TimeoutSocket extends Socket 39 { 40 private Socket s; 41 42 public TimeoutSocket(Socket s) 43 { 44 this.s = s; 45 } 46 47 public InetAddress getInetAddress() 48 { 49 return s.getInetAddress(); 50 } 51 52 public InetAddress getLocalAddress() 53 { 54 return s.getLocalAddress(); 55 } 56 57 public int getPort() 58 { 59 return s.getPort(); 60 } 61 62 public int getLocalPort() 63 { 64 return s.getLocalPort(); 65 } 66 67 public SocketAddress getRemoteSocketAddress() 68 { 69 return s.getRemoteSocketAddress(); 70 } 71 72 public SocketAddress getLocalSocketAddress() 73 { 74 return s.getLocalSocketAddress(); 75 } 76 77 public SocketChannel getChannel() 78 { 79 return s.getChannel(); 80 } 81 82 public InputStream getInputStream() throws IOException 83 { 84 InputStream is = s.getInputStream(); 85 InterruptableInputStream iis = new InterruptableInputStream(is); 86 return iis; 87 } 88 89 public OutputStream getOutputStream() throws IOException 90 { 91 return s.getOutputStream(); 92 } 93 94 public void setTcpNoDelay(boolean on) throws SocketException 95 { 96 s.setTcpNoDelay(on); 97 } 98 99 public boolean getTcpNoDelay() throws SocketException 100 { 101 return s.getTcpNoDelay(); 102 } 103 104 public void setSoLinger(boolean on, int linger) throws SocketException 105 { 106 s.setSoLinger(on, linger); 107 } 108 109 public int getSoLinger() throws SocketException 110 { 111 return s.getSoLinger(); 112 } 113 114 public void sendUrgentData(int data) throws IOException 115 { 116 s.sendUrgentData(data); 117 } 118 119 public void setOOBInline(boolean on) throws SocketException 120 { 121 s.setOOBInline(on); 122 } 123 124 public boolean getOOBInline() throws SocketException 125 { 126 return s.getOOBInline(); 127 } 128 129 public synchronized void setSoTimeout(int timeout) throws SocketException 130 { 131 s.setSoTimeout(1000); 132 } 133 134 public synchronized int getSoTimeout() throws SocketException 135 { 136 return s.getSoTimeout(); 137 } 138 139 public synchronized void setSendBufferSize(int size) throws SocketException 140 { 141 s.setSendBufferSize(size); 142 } 143 144 public synchronized int getSendBufferSize() throws SocketException 145 { 146 return s.getSendBufferSize(); 147 } 148 149 public synchronized void setReceiveBufferSize(int size) throws SocketException 150 { 151 s.setReceiveBufferSize(size); 152 } 153 154 public synchronized int getReceiveBufferSize() throws SocketException 155 { 156 return s.getReceiveBufferSize(); 157 } 158 159 public void setKeepAlive(boolean on) throws SocketException 160 { 161 s.setKeepAlive(on); 162 } 163 164 public boolean getKeepAlive() throws SocketException 165 { 166 return s.getKeepAlive(); 167 } 168 169 public void setTrafficClass(int tc) throws SocketException 170 { 171 s.setTrafficClass(tc); 172 } 173 174 public int getTrafficClass() throws SocketException 175 { 176 return s.getTrafficClass(); 177 } 178 179 public void setReuseAddress(boolean on) throws SocketException 180 { 181 s.setReuseAddress(on); 182 } 183 184 public boolean getReuseAddress() throws SocketException 185 { 186 return s.getReuseAddress(); 187 } 188 189 public synchronized void close() throws IOException 190 { 191 s.close(); 192 } 193 194 public void shutdownInput() throws IOException 195 { 196 s.shutdownInput(); 197 } 198 199 public void shutdownOutput() throws IOException 200 { 201 s.shutdownOutput(); 202 } 203 204 public String toString() 205 { 206 return s.toString(); 207 } 208 209 public boolean isConnected() 210 { 211 return s.isConnected(); 212 } 213 214 public boolean isBound() 215 { 216 return s.isBound(); 217 } 218 219 public boolean isClosed() 220 { 221 return s.isClosed(); 222 } 223 224 public boolean isInputShutdown() 225 { 226 return s.isInputShutdown(); 227 } 228 229 public boolean isOutputShutdown() 230 { 231 return s.isOutputShutdown(); 232 } 233 } 234 | Popular Tags |