1 7 8 package java.net; 9 10 import java.io.IOException ; 11 import java.io.InputStream ; 12 import java.io.OutputStream ; 13 import java.io.FileDescriptor ; 14 15 27 public abstract class SocketImpl implements SocketOptions { 28 31 Socket socket = null; 32 ServerSocket serverSocket = null; 33 34 37 protected FileDescriptor fd; 38 39 42 protected InetAddress address; 43 44 47 protected int port; 48 49 52 protected int localport; 53 54 62 protected abstract void create(boolean stream) throws IOException ; 63 64 72 protected abstract void connect(String host, int port) throws IOException ; 73 74 82 protected abstract void connect(InetAddress address, int port) throws IOException ; 83 84 95 protected abstract void connect(SocketAddress address, int timeout) throws IOException ; 96 97 104 protected abstract void bind(InetAddress host, int port) throws IOException ; 105 106 115 protected abstract void listen(int backlog) throws IOException ; 116 117 124 protected abstract void accept(SocketImpl s) throws IOException ; 125 126 133 protected abstract InputStream getInputStream() throws IOException ; 134 135 142 protected abstract OutputStream getOutputStream() throws IOException ; 143 144 153 protected abstract int available() throws IOException ; 154 155 160 protected abstract void close() throws IOException ; 161 162 176 protected void shutdownInput() throws IOException { 177 throw new IOException ("Method not implemented!"); 178 } 179 180 195 protected void shutdownOutput() throws IOException { 196 throw new IOException ("Method not implemented!"); 197 } 198 199 205 protected FileDescriptor getFileDescriptor() { 206 return fd; 207 } 208 209 215 protected InetAddress getInetAddress() { 216 return address; 217 } 218 219 225 protected int getPort() { 226 return port; 227 } 228 229 238 protected boolean supportsUrgentData () { 239 return false; } 241 242 250 protected abstract void sendUrgentData (int data) throws IOException ; 251 252 258 protected int getLocalPort() { 259 return localport; 260 } 261 262 void setSocket(Socket soc) { 263 this.socket = soc; 264 } 265 266 Socket getSocket() { 267 return socket; 268 } 269 270 void setServerSocket(ServerSocket soc) { 271 this.serverSocket = soc; 272 } 273 274 ServerSocket getServerSocket() { 275 return serverSocket; 276 } 277 278 283 public String toString() { 284 return "Socket[addr=" + getInetAddress() + 285 ",port=" + getPort() + ",localport=" + getLocalPort() + "]"; 286 } 287 288 void reset() throws IOException { 289 address = null; 290 port = 0; 291 localport = 0; 292 close(); 293 } 294 295 333 protected void setPerformancePreferences(int connectionTime, 334 int latency, 335 int bandwidth) 336 { 337 338 } 339 } 340 | Popular Tags |