1 package org.sapia.ubik.net.mplex; 2 3 import java.io.IOException ; 4 5 import java.net.InetAddress ; 6 import java.net.Socket ; 7 import java.net.SocketAddress ; 8 import java.net.SocketException ; 9 10 11 23 public class SocketConnectorImpl implements MultiplexSocketConnector { 24 25 private MultiplexServerSocket _theServerSocket; 26 27 28 private StreamSelector _theSelector; 29 30 31 private SocketQueue _theQueue; 32 33 34 private boolean _isClosed; 35 36 39 public SocketConnectorImpl(MultiplexServerSocket aServerSocket, 40 StreamSelector aSelector, SocketQueue aQueue) { 41 _theServerSocket = aServerSocket; 42 _theSelector = aSelector; 43 _theQueue = aQueue; 44 _isClosed = false; 45 } 46 47 52 public StreamSelector getSelector() { 53 return _theSelector; 54 } 55 56 61 public SocketQueue getQueue() { 62 return _theQueue; 63 } 64 65 71 public int getLocalPort() { 72 return _theServerSocket.getLocalPort(); 73 } 74 75 81 public InetAddress getInetAddress() { 82 return _theServerSocket.getInetAddress(); 83 } 84 85 92 public SocketAddress getLocalSocketAddress() { 93 return _theServerSocket.getLocalSocketAddress(); 94 } 95 96 104 public int getReceiveBufferSize() throws SocketException { 105 return _theServerSocket.getReceiveBufferSize(); 106 } 107 108 114 public boolean getReuseAddress() throws SocketException { 115 return _theServerSocket.getReuseAddress(); 116 } 117 118 124 public int getSoTimeout() throws IOException { 125 return _theServerSocket.getSoTimeout(); 126 } 127 128 133 public boolean isBound() { 134 return _theServerSocket.isBound(); 135 } 136 137 142 public boolean isClosed() { 143 return _isClosed || _theServerSocket.isClosed(); 144 } 145 146 153 public Socket accept() throws IOException { 154 return _theQueue.getSocket(); 155 } 156 157 162 public void close() throws IOException { 163 _theServerSocket.removeSocketConnector(this); 164 _theQueue.close(); 165 _isClosed = true; 166 } 167 } 168 | Popular Tags |