protected void clear(int op) { try { clearSelectionKey(op); } catch(Throwable t) { } }
protected void writeInterest(boolean register) { if(register) { if(!write_interest_set) { write_interest_set=true; registerSelectionKey(SelectionKey.OP_WRITE); } } else { if(write_interest_set) { write_interest_set=false; clearSelectionKey(SelectionKey.OP_WRITE); } } }
SocketChannel ch=(SocketChannel)key.channel(); if(ch.finishConnect() || ch.isConnected()) { conn.clearSelectionKey(SelectionKey.OP_CONNECT); conn.connected(true);
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; } }
protected void clear(int op) { try { clearSelectionKey(op); } catch(Throwable t) { } }
protected void writeInterest(boolean register) { if(register) { if(!write_interest_set) { write_interest_set=true; registerSelectionKey(SelectionKey.OP_WRITE); } } else { if(write_interest_set) { write_interest_set=false; clearSelectionKey(SelectionKey.OP_WRITE); } } }
SocketChannel ch=(SocketChannel)key.channel(); if(ch.finishConnect() || ch.isConnected()) { conn.clearSelectionKey(SelectionKey.OP_CONNECT); conn.connected(true);
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; } }