@Override public InetSocketAddress address() { Channel c = channel(); if (c instanceof SocketChannel) { return ((SocketChannel) c).remoteAddress(); } if (c instanceof DatagramChannel) { InetSocketAddress a = ((DatagramChannel) c).remoteAddress(); return a != null ? a : ((DatagramChannel)c ).localAddress(); } throw new IllegalStateException("Does not have an InetSocketAddress"); }
/** * Return local server selector channel address. * * @return local {@link InetSocketAddress} */ default InetSocketAddress address(){ Channel c = channel(); if (c instanceof SocketChannel) { return ((SocketChannel) c).remoteAddress(); } if (c instanceof ServerSocketChannel) { return ((ServerSocketChannel) c).localAddress(); } if (c instanceof DatagramChannel) { InetSocketAddress a = ((DatagramChannel) c).remoteAddress(); return a != null ? a : ((DatagramChannel)c ).localAddress(); } throw new IllegalStateException("Does not have an InetSocketAddress"); }
/** * Return local server selector channel address. * * @return local {@link InetSocketAddress} */ default InetSocketAddress address(){ Channel c = channel(); if (c instanceof SocketChannel) { return ((SocketChannel) c).remoteAddress(); } if (c instanceof ServerSocketChannel) { return ((ServerSocketChannel) c).localAddress(); } if (c instanceof DatagramChannel) { InetSocketAddress a = ((DatagramChannel) c).remoteAddress(); return a != null ? a : ((DatagramChannel)c ).localAddress(); } throw new IllegalStateException("Does not have an InetSocketAddress"); }
/** * Return remote address if remote channel {@link NettyContext} otherwise local * address if server selector channel. * * @return remote or local {@link InetSocketAddress} */ default InetSocketAddress address(){ Channel c = channel(); if (c instanceof SocketChannel) { return ((SocketChannel) c).remoteAddress(); } if (c instanceof ServerSocketChannel) { return ((ServerSocketChannel) c).localAddress(); } if (c instanceof DatagramChannel) { InetSocketAddress a = ((DatagramChannel) c).remoteAddress(); return a != null ? a : ((DatagramChannel)c ).localAddress(); } throw new IllegalStateException("Does not have an InetSocketAddress"); }