@Override public Address localAddress() { InetSocketAddress local_addr=null; if(channel != null) { try {local_addr=(InetSocketAddress)channel.getLocalAddress();} catch(IOException e) {} } return local_addr != null? new IpAddress(local_addr) : null; }
@Override public String getSocketChannelLocalAddress() { try { if(getChannel() != null) { return getChannel().getLocalAddress().toString(); } } catch (IOException e) { log.error("Exception", e); } return "NULL"; }
public String toString() { InetSocketAddress local=null, remote=null; try {local=channel != null? (InetSocketAddress)channel.getLocalAddress() : null;} catch(Throwable t) {} try {remote=channel != null? (InetSocketAddress)channel.getRemoteAddress() : null;} catch(Throwable t) {} String loc=local == null ? "n/a" : local.getHostString() + ":" + local.getPort(), rem=remote == null? "n/a" : remote.getHostString() + ":" + remote.getPort(); return String.format("<%s --> %s> (%d secs old) [%s] [recv_buf: %d, reader=%b]", loc, rem, TimeUnit.SECONDS.convert(getTimestamp() - last_access, TimeUnit.NANOSECONDS), status(), recv_buf.get(1) != null? recv_buf.get(1).capacity() : 0, readerRunning()); }
final SocketAddress localAddress = channel.getLocalAddress(); if (localAddress != null && localAddress instanceof InetSocketAddress) { final InetSocketAddress inetSocketAddress = (InetSocketAddress) localAddress;
protected void connect(Address dest, boolean send_local_addr) throws Exception { SocketAddress destAddr=new InetSocketAddress(((IpAddress)dest).getIpAddress(), ((IpAddress)dest).getPort()); try { if(!server.deferClientBinding()) this.channel.bind(new InetSocketAddress(server.clientBindAddress(), server.clientBindPort())); this.key=server.register(channel, SelectionKey.OP_CONNECT | SelectionKey.OP_READ, this); if(Util.connect(channel, destAddr) && channel.finishConnect()) { clearSelectionKey(SelectionKey.OP_CONNECT); this.connected=channel.isConnected(); } if(this.channel.getLocalAddress() != null && this.channel.getLocalAddress().equals(destAddr)) throw new IllegalStateException("socket's bind and connect address are the same: " + destAddr); if(send_local_addr) sendLocalAddress(server.localAddress()); } catch(Exception t) { close(); throw t; } }
accepted = channel.accept(); if (accepted != null) try { final SocketAddress localAddress = accepted.getLocalAddress(); int hash; if (localAddress instanceof InetSocketAddress) {
boolean ok = false; if (accepted != null) try { final SocketAddress localAddress = accepted.getLocalAddress(); int hash; if (localAddress instanceof InetSocketAddress) {
} catch (final SSLException sslException) { s_logger.error(String.format("SSL error caught during wrap data: %s, for local address=%s, remote address=%s.", sslException.getMessage(), socketChannel.getLocalAddress(), socketChannel.getRemoteAddress())); sslEngine.closeOutbound(); return new HandshakeHolder(myAppData, myNetData, true);
} catch (final SSLException sslException) { s_logger.error(String.format("SSL error caught during unwrap data: %s, for local address=%s, remote address=%s. The client may have invalid ca-certificates.", sslException.getMessage(), socketChannel.getLocalAddress(), socketChannel.getRemoteAddress())); sslEngine.closeOutbound(); return new HandshakeHolder(peerAppData, peerNetData, false);
/** * {@inheritDoc} * * Forwards to {@link #delegate}. */ @Override public SocketAddress getLocalAddress() throws IOException { return delegate.getLocalAddress(); }
public static InetAddress getLocalAdress(String remoteHost, int port) throws IOException { InetSocketAddress socketAddr = new InetSocketAddress(remoteHost, port); SocketChannel socketChannel = SocketChannel.open(socketAddr); InetSocketAddress localAddress = (InetSocketAddress) socketChannel.getLocalAddress(); return localAddress.getAddress(); } }
@Override public Address localAddress() { InetSocketAddress local_addr=null; if(channel != null) { try {local_addr=(InetSocketAddress)channel.getLocalAddress();} catch(IOException e) {} } return local_addr != null? new IpAddress(local_addr) : null; }
@Override public Address localAddress() { InetSocketAddress local_addr=null; if(channel != null) { try {local_addr=(InetSocketAddress)channel.getLocalAddress();} catch(IOException e) {} } return local_addr != null? new IpAddress(local_addr) : null; }
@Override public InetSocketAddress getLocalAddress() throws IORuntimeException { try { return (InetSocketAddress) socketChannel.getLocalAddress(); } catch (IOException e) { throw new IORuntimeException(e); } }
@Override public InetSocketAddress getLocalAddress() throws IORuntimeException { try { return (InetSocketAddress) socketChannel.getLocalAddress(); } catch (IOException e) { throw new IORuntimeException(e); } }
@Override public Address localAddress() { InetSocketAddress local_addr=null; if(channel != null) { try {local_addr=(InetSocketAddress)channel.getLocalAddress();} catch(IOException e) {} } return local_addr != null? new IpAddress(local_addr) : null; }
public String toString() { InetSocketAddress local=null, remote=null; try {local=channel != null? (InetSocketAddress)channel.getLocalAddress() : null;} catch(Throwable t) {} try {remote=channel != null? (InetSocketAddress)channel.getRemoteAddress() : null;} catch(Throwable t) {} String loc=local == null ? "n/a" : local.getHostString() + ":" + local.getPort(), rem=remote == null? "n/a" : remote.getHostString() + ":" + remote.getPort(); return String.format("<%s --> %s> (%d secs old) [%s] [recv_buf: %d, reader=%b]", loc, rem, TimeUnit.SECONDS.convert(getTimestamp() - last_access, TimeUnit.NANOSECONDS), status(), recv_buf.get(1) != null? recv_buf.get(1).capacity() : 0, readerRunning()); }
public String toString() { InetSocketAddress local=null, remote=null; try {local=channel != null? (InetSocketAddress)channel.getLocalAddress() : null;} catch(Throwable t) {} try {remote=channel != null? (InetSocketAddress)channel.getRemoteAddress() : null;} catch(Throwable t) {} String loc=local == null ? "n/a" : local.getHostString() + ":" + local.getPort(), rem=remote == null? "n/a" : remote.getHostString() + ":" + remote.getPort(); return String.format("<%s --> %s> (%d secs old) [%s] [recv_buf: %d, reader=%b]", loc, rem, TimeUnit.SECONDS.convert(getTimestamp() - last_access, TimeUnit.NANOSECONDS), status(), recv_buf.get(1) != null? recv_buf.get(1).capacity() : 0, readerRunning()); }
public String toString() { InetSocketAddress local=null, remote=null; try {local=channel != null? (InetSocketAddress)channel.getLocalAddress() : null;} catch(Throwable t) {} try {remote=channel != null? (InetSocketAddress)channel.getRemoteAddress() : null;} catch(Throwable t) {} String loc=local == null ? "n/a" : local.getHostString() + ":" + local.getPort(), rem=remote == null? "n/a" : remote.getHostString() + ":" + remote.getPort(); return String.format("<%s --> %s> (%d secs old) [%s] [recv_buf: %d, reader=%b]", loc, rem, TimeUnit.SECONDS.convert(getTimestamp() - last_access, TimeUnit.NANOSECONDS), status(), recv_buf.get(1) != null? recv_buf.get(1).capacity() : 0, readerRunning()); }
private String getConnectionInfo() { try { return getSocketChannel().getLocalAddress() + " -> " + getSocketChannel().getRemoteAddress(); } catch (IOException e) { LOGGER.warn("failed to get connection info", e); return ""; } }