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

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

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

SocketChannel.shutdownOutput介绍

暂无

代码示例

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

@Override
public void shutdownOutput() throws IOException {
  ch.shutdownOutput().syncUninterruptibly();
}

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

private void testShutdownSoLingerNoAssertError0(Bootstrap cb, boolean output) throws Throwable {
  ServerSocket ss = new ServerSocket();
  Socket s = null;
  ChannelFuture cf = null;
  try {
    ss.bind(newSocketAddress());
    cf = cb.option(ChannelOption.SO_LINGER, 1).handler(new ChannelInboundHandlerAdapter())
        .connect(ss.getLocalSocketAddress()).sync();
    s = ss.accept();
    cf.sync();
    if (output) {
      ((SocketChannel) cf.channel()).shutdownOutput().sync();
    } else {
      ((SocketChannel) cf.channel()).shutdown().sync();
    }
  } finally {
    if (s != null) {
      s.close();
    }
    if (cf != null) {
      cf.channel().close();
    }
    ss.close();
  }
}
private static void checkThrowable(Throwable cause) throws Throwable {

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

public void testShutdownOutputAfterClosed(Bootstrap cb) throws Throwable {
  TestHandler h = new TestHandler();
  ServerSocket ss = new ServerSocket();
  Socket s = null;
  try {
    ss.bind(newSocketAddress());
    SocketChannel ch = (SocketChannel) cb.handler(h).connect(ss.getLocalSocketAddress()).sync().channel();
    assertTrue(ch.isActive());
    s = ss.accept();
    ch.close().syncUninterruptibly();
    try {
      ch.shutdownInput().syncUninterruptibly();
      fail();
    } catch (Throwable cause) {
      checkThrowable(cause);
    }
    try {
      ch.shutdownOutput().syncUninterruptibly();
      fail();
    } catch (Throwable cause) {
      checkThrowable(cause);
    }
  } finally {
    if (s != null) {
      s.close();
    }
    ss.close();
  }
}

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

ch.shutdownOutput().sync();
assertEquals(-1, s.getInputStream().read());

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

ch.shutdownOutput().sync();
assertEquals(-1, s.getInputStream().read());

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

public void testShutdownNotYetConnected(Bootstrap cb) throws Throwable {
  SocketChannel ch = (SocketChannel) cb.handler(new ChannelInboundHandlerAdapter())
      .bind(newSocketAddress()).syncUninterruptibly().channel();
  try {
    try {
      ch.shutdownInput().syncUninterruptibly();
      fail();
    } catch (Throwable cause) {
      checkThrowable(cause);
    }
    try {
      ch.shutdownOutput().syncUninterruptibly();
      fail();
    } catch (Throwable cause) {
      checkThrowable(cause);
    }
  } finally {
    ch.close().syncUninterruptibly();
  }
}

相关文章