io.netty.channel.socket.SocketChannel.isOpen()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(163)

本文整理了Java中io.netty.channel.socket.SocketChannel.isOpen()方法的一些代码示例,展示了SocketChannel.isOpen()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SocketChannel.isOpen()方法的具体详情如下:
包路径:io.netty.channel.socket.SocketChannel
类名称:SocketChannel
方法名:isOpen

SocketChannel.isOpen介绍

暂无

代码示例

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

@Override
 public boolean apply(SocketChannel input) {
  return input.isOpen();
 }
};

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

@Override
 public boolean apply(SocketChannel input) {
  return input.isOpen()
    && input.remoteAddress() != null
    && addresses.contains(input.remoteAddress());
 }
}));

代码示例来源:origin: aadnk/ProtocolLib

@Override
public boolean isClosed() {
  return !ch.isOpen();
}

代码示例来源:origin: com.datastax.dse/dse-java-driver-core

@Override
 public boolean apply(SocketChannel input) {
  return input.isOpen();
 }
};

代码示例来源:origin: com.datastax.dse/dse-java-driver-core

@Override
 public boolean apply(SocketChannel input) {
  return input.isOpen()
    && input.remoteAddress() != null
    && addresses.contains(input.remoteAddress());
 }
}));

代码示例来源:origin: io.netty/netty-testsuite

public void testShutdownOutput(ServerBootstrap sb) throws Throwable {
  TestHandler h = new TestHandler();
  Socket s = new Socket();
  Channel sc = null;
  try {
    sc = sb.childHandler(h).childOption(ChannelOption.ALLOW_HALF_CLOSURE, true).bind().sync().channel();
    SocketUtils.connect(s, sc.localAddress(), 10000);
    s.getOutputStream().write(1);
    assertEquals(1, (int) h.queue.take());
    assertTrue(h.ch.isOpen());
    assertTrue(h.ch.isActive());
    assertFalse(h.ch.isInputShutdown());
    assertFalse(h.ch.isOutputShutdown());
    s.shutdownOutput();
    h.halfClosure.await();
    assertTrue(h.ch.isOpen());
    assertTrue(h.ch.isActive());
    assertTrue(h.ch.isInputShutdown());
    assertFalse(h.ch.isOutputShutdown());
    assertEquals(1, h.closure.getCount());
    Thread.sleep(100);
    assertEquals(1, h.halfClosureCount.intValue());
  } finally {
    if (sc != null) {
      sc.close();
    }
    s.close();
  }
}

代码示例来源:origin: io.netty/netty-testsuite

public void testShutdownOutputWithoutOption(ServerBootstrap sb) throws Throwable {
  TestHandler h = new TestHandler();
  Socket s = new Socket();
  Channel sc = null;
  try {
    sc = sb.childHandler(h).bind().sync().channel();
    SocketUtils.connect(s, sc.localAddress(), 10000);
    s.getOutputStream().write(1);
    assertEquals(1, (int) h.queue.take());
    assertTrue(h.ch.isOpen());
    assertTrue(h.ch.isActive());
    assertFalse(h.ch.isInputShutdown());
    assertFalse(h.ch.isOutputShutdown());
    s.shutdownOutput();
    h.closure.await();
    assertFalse(h.ch.isOpen());
    assertFalse(h.ch.isActive());
    assertTrue(h.ch.isInputShutdown());
    assertTrue(h.ch.isOutputShutdown());
    assertEquals(1, h.halfClosure.getCount());
    Thread.sleep(100);
    assertEquals(0, h.halfClosureCount.intValue());
  } finally {
    if (sc != null) {
      sc.close();
    }
    s.close();
  }
}

代码示例来源:origin: io.netty/netty-testsuite

assertEquals(1, s.getInputStream().read());
assertTrue(h.ch.isOpen());
assertTrue(h.ch.isActive());
assertFalse(h.ch.isInputShutdown());
assertEquals(-1, s.getInputStream().read());
assertTrue(h.ch.isOpen());
assertTrue(h.ch.isActive());
assertFalse(h.ch.isInputShutdown());

代码示例来源:origin: io.netty/netty-testsuite

assertTrue(h.ch.isOpen());
assertTrue(h.ch.isActive());
assertFalse(h.ch.isInputShutdown());
assertEquals(-1, s.getInputStream().read());
assertTrue(h.ch.isOpen());
assertTrue(h.ch.isActive());
assertFalse(h.ch.isInputShutdown());

代码示例来源:origin: org.neo4j/neo4j-causal-clustering

/**
 * schedules the handshake initiation after the connection attempt
 */
private void scheduleHandshake( SocketChannel ch, HandshakeClient handshakeClient, TimeoutStrategy.Timeout handshakeDelay )
{
  ch.eventLoop().schedule( () ->
  {
    if ( ch.isActive() )
    {
      initiateHandshake( ch, handshakeClient );
    }
    else if ( ch.isOpen() )
    {
      handshakeDelay.increment();
      scheduleHandshake( ch, handshakeClient, handshakeDelay );
    }
    else
    {
      handshakeClient.failIfNotDone( "Channel closed" );
    }
  }, handshakeDelay.getMillis(), MILLISECONDS );
}

相关文章