@Override public boolean isConnected() { return socketChannel.isConnected(); }
@Override public boolean isConnected() { return socketChannel.isConnected(); }
public boolean isConnected() { return socketChannel.isConnected(); }
/** * Returns true if the channel for this key is connected. If the channel * does not need connecting, this always return true. */ boolean isConnected() { return !(channel instanceof SocketChannel) || ((SocketChannel) channel).isConnected(); } }
public boolean isConnected() { return socket.isConnected(); }
@Override public boolean isClosed() { return !channel.isConnected(); }
@Override public boolean isConnected() { return channel != null && channel.isConnected(); }
public boolean isConnected() { return socketChannel.isConnected(); }
@Override public boolean isActive() { SocketChannel ch = javaChannel(); return ch.isOpen() && ch.isConnected(); }
private void write(SocketChannel socketChannel, ByteBuffer buffer) throws IOException { while (buffer.hasRemaining() && socketChannel.isConnected()) { if (-1 == socketChannel.write(buffer)) { // socket broken throw new IOException("write EOF"); } } }
@Override public boolean isActive() { SocketChannel ch = javaChannel(); return ch.isOpen() && ch.isConnected(); }
@Override public boolean isActive() { SocketChannel ch = javaChannel(); return ch.isOpen() && ch.isConnected(); }
public SSLSocketChannel(final SSLContext sslContext, final SocketChannel socketChannel, final boolean client) throws IOException { if (!socketChannel.isConnected()) { throw new IllegalArgumentException("Cannot pass an un-connected SocketChannel"); } this.channel = socketChannel; this.socketAddress = socketChannel.getRemoteAddress(); final Socket socket = socketChannel.socket(); this.hostname = socket.getInetAddress().getHostName(); this.port = socket.getPort(); this.engine = sslContext.createSSLEngine(); this.engine.setUseClientMode(client); this.engine.setNeedClientAuth(true); streamInManager = new BufferStateManager(ByteBuffer.allocate(engine.getSession().getPacketBufferSize())); streamOutManager = new BufferStateManager(ByteBuffer.allocate(engine.getSession().getPacketBufferSize())); appDataManager = new BufferStateManager(ByteBuffer.allocate(engine.getSession().getApplicationBufferSize())); }
public SSLSocketChannel(final SSLEngine sslEngine, final SocketChannel socketChannel) throws IOException { if (!socketChannel.isConnected()) { throw new IllegalArgumentException("Cannot pass an un-connected SocketChannel"); } this.channel = socketChannel; this.socketAddress = socketChannel.getRemoteAddress(); final Socket socket = socketChannel.socket(); this.hostname = socket.getInetAddress().getHostName(); this.port = socket.getPort(); // don't set useClientMode or needClientAuth, use the engine as is and let the caller configure it this.engine = sslEngine; streamInManager = new BufferStateManager(ByteBuffer.allocate(engine.getSession().getPacketBufferSize())); streamOutManager = new BufferStateManager(ByteBuffer.allocate(engine.getSession().getPacketBufferSize())); appDataManager = new BufferStateManager(ByteBuffer.allocate(engine.getSession().getApplicationBufferSize())); }
@Override public void run() { if (key != null && key.isValid()) { SocketChannel channel = (SocketChannel) key.channel(); Beat beat = (Beat) key.attachment(); if (channel.isConnected()) { return; } try { channel.finishConnect(); } catch (Exception ignore) { } try { beat.finishCheck(false, false, beat.getTask().getCheckRTNormalized() * 2, "tcp:timeout"); key.cancel(); key.channel().close(); } catch (Exception ignore) { } } } }
@Override public boolean isClosed() { boolean closed = !socketChannel.isConnected(); if (!closed) { try { this.in.isDataAvailable(); } catch (IOException e) { try { close(); } catch (IOException e1) { } closed = true; } } return closed; }
public void disconnect() throws CanalClientException { if (rollbackOnDisConnect && channel.isConnected()) { rollback(); } connected = false; if (runningMonitor != null) { if (runningMonitor.isStart()) { runningMonitor.stop(); } } else { doDisconnect(); } }
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) }
@Override protected void startHandshake() throws IOException { assertTrue("SSL handshake initialized too early", socketChannel().isConnected()); super.startHandshake(); }
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; } }