TcpIpConnection newConnection(SocketChannelWrapper channel, Address endpoint) { TcpIpConnection connection = new TcpIpConnection(this, connectionIdGen.incrementAndGet(), channel, ioThreadingModel); connection.setEndPoint(endpoint); activeConnections.add(connection); acceptedSockets.remove(channel); connection.start(); ioThreadingModel.onConnectionAdded(connection); logger.info( "Established socket connection between " + channel.socket().getLocalSocketAddress() + " and " + channel.socket().getRemoteSocketAddress()); openedCount.inc(); return connection; }
Object getConnectionAddress() { return (endPoint == null) ? socketChannel.socket().getRemoteSocketAddress() : endPoint; }
@Override public int getPort() { return socketChannel.socket().getPort(); }
@Override public InetSocketAddress getRemoteSocketAddress() { return (InetSocketAddress) socketChannel.socket().getRemoteSocketAddress(); }
@Override public InetAddress getInetAddress() { return socketChannel.socket().getInetAddress(); }