/** 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 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) }
/** 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 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) }