protected void updateLastAccessed() { if(server.connExpireTime() > 0) last_access=getTimestamp(); }
/** Creates a connection stub and binds it, use {@link #connect(Address)} to connect */ public NioConnection(Address peer_addr, NioBaseServer server) throws Exception { this.server=server; if(peer_addr == null) throw new IllegalArgumentException("Invalid parameter peer_addr="+ peer_addr); this.peer_addr=peer_addr; send_buf=new Buffers(server.maxSendBuffers() *2); // space for actual bufs and length bufs! channel=SocketChannel.open(); channel.configureBlocking(false); setSocketParameters(channel.socket()); last_access=getTimestamp(); // last time a message was sent or received (ns) }
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 NioConnection(SocketChannel channel, NioBaseServer server) throws Exception { this.channel=channel; this.server=server; setSocketParameters(this.channel.socket()); channel.configureBlocking(false); this.connected=channel.isConnected(); send_buf=new Buffers(server.maxSendBuffers() *2); // space for actual bufs and length bufs! this.peer_addr=server.usePeerConnections()? null /* read by first receive() */ : new IpAddress((InetSocketAddress)channel.getRemoteAddress()); last_access=getTimestamp(); // last time a message was sent or received (ns) }
protected void updateLastAccessed() { if(server.connExpireTime() > 0) last_access=getTimestamp(); }
/** Creates a connection stub and binds it, use {@link #connect(Address)} to connect */ public NioConnection(Address peer_addr, NioBaseServer server) throws Exception { this.server=server; if(peer_addr == null) throw new IllegalArgumentException("Invalid parameter peer_addr="+ peer_addr); this.peer_addr=peer_addr; send_buf=new Buffers(server.maxSendBuffers() *2); // space for actual bufs and length bufs! channel=SocketChannel.open(); channel.configureBlocking(false); setSocketParameters(channel.socket()); last_access=getTimestamp(); // last time a message was sent or received (ns) }
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 NioConnection(SocketChannel channel, NioBaseServer server) throws Exception { this.channel=channel; this.server=server; setSocketParameters(this.channel.socket()); channel.configureBlocking(false); this.connected=channel.isConnected(); send_buf=new Buffers(server.maxSendBuffers() *2); // space for actual bufs and length bufs! this.peer_addr=server.usePeerConnections()? null /* read by first receive() */ : new IpAddress((InetSocketAddress)channel.getRemoteAddress()); last_access=getTimestamp(); // last time a message was sent or received (ns) }