public void listenUDP(EndPoint localEp) { UdpConnection connection = new UdpConnection(); logger_.debug("Starting to listen on " + localEp); try { connection.init(localEp.getPort()); endPoints_.add(localEp); } catch (IOException e) { logger_.warn(LogUtil.throwableToString(e)); } }
public static ConnectionStatistics[] getPoolStatistics() { Set<ConnectionStatistics> stats = new HashSet<ConnectionStatistics>(); Iterator<TcpConnectionManager> it = poolTable_.values().iterator(); while (it.hasNext()) { TcpConnectionManager cp = it.next(); ConnectionStatistics cs = new ConnectionStatistics( cp.getLocalEndPoint(), cp.getRemoteEndPoint(), cp.getPoolSize(), cp.getConnectionsInUse()); stats.add(cs); } return stats.toArray(new ConnectionStatistics[0]); }
public void listen(EndPoint localEp, boolean isHttp) throws IOException { ServerSocketChannel serverChannel = ServerSocketChannel.open(); ServerSocket ss = serverChannel.socket(); ss.bind(localEp.getInetAddress()); serverChannel.configureBlocking(false); SelectionKeyHandler handler = null; if (isHttp) { handler = new HttpConnectionHandler(); } else { handler = new TcpConnectionHandler(localEp); } SelectionKey key = SelectorManager.getSelectorManager() .register(serverChannel, handler, SelectionKey.OP_ACCEPT); endPoints_.add(localEp); listenSockets_.put(localEp, key); }