本文整理了Java中io.netty.channel.socket.SocketChannel.close()
方法的一些代码示例,展示了SocketChannel.close()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SocketChannel.close()
方法的具体详情如下:
包路径:io.netty.channel.socket.SocketChannel
类名称:SocketChannel
方法名:close
暂无
代码示例来源:origin: crossoverJie/cim
/**
* 关闭
*
* @throws InterruptedException
*/
public void close() throws InterruptedException {
if (channel != null){
channel.close();
}
}
}
代码示例来源:origin: aerospike/aerospike-client-java
/**
* Close connection.
*/
@Override
public void close() {
channel.close();
}
}
代码示例来源:origin: com.aerospike/aerospike-client
/**
* Close connection.
*/
@Override
public void close() {
channel.close();
}
}
代码示例来源:origin: dremio/dremio-oss
@Override
public void close() {
logger.debug("Closing client");
try {
if (connection != null) {
connection.getChannel().close().sync();
}
} catch (final InterruptedException e) {
logger.warn("Failure while shutting {}", this.getClass().getName(), e);
// Preserve evidence that the interruption occurred so that code higher up on the call stack can learn of the
// interruption and respond to it if it wants to.
Thread.currentThread().interrupt();
}
}
代码示例来源:origin: aadnk/ProtocolLib
@Override
public synchronized void close() throws IOException {
ch.close().syncUninterruptibly();
}
代码示例来源:origin: dremio/dremio-oss
@Override
public void close() {
if (closed.getAndSet(true)) {
// Connection was already closed. Let's print out
logger.info("Attempting to close connection again");
}
CONNECTION_TYPE c = connectionHolder.getAndSet(null);
if (c != null) {
try {
c.getChannel().close().sync();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}
}
代码示例来源:origin: io.netty/netty-testsuite
public void testWriteBeforeConnect(Bootstrap cb) throws Throwable {
TestHandler h = new TestHandler();
SocketChannel ch = null;
try {
ch = (SocketChannel) cb.handler(h).connect(newSocketAddress()).channel();
ch.writeAndFlush(Unpooled.wrappedBuffer(new byte[] { 1 }));
} finally {
if (ch != null) {
ch.close();
}
}
}
代码示例来源:origin: dremio/dremio-oss
/**
* Connection consumer wants to close connection. Initiate connection close
* and complete. This is a blocking call that ensures that the connection is
* closed before returning. As part of this call, the channel close handler
* will be triggered which will call channelClosed() above. The latter will
* happen in a separate thread while this method is blocking.
*/
@Override
public void close() {
try {
if (channel.isActive()) {
channel.close().get();
}
} catch (final InterruptedException | ExecutionException e) {
logger.warn("Caught exception while closing channel.", e);
// Preserve evidence that the interruption occurred so that code higher up
// on the call stack can learn of the
// interruption and respond to it if it wants to.
Thread.currentThread().interrupt();
}
}
代码示例来源:origin: waterguo/antsdb
@Override
public void initChannel(SocketChannel ch) throws Exception {
_log.trace("channel initialized with remote address {}", ch.remoteAddress());
if (this.fish.getOrca() == null) {
// orca not initialized
ch.close();
return;
}
MysqlServerHandler handler = new MysqlServerHandler(fish, ch);
ch.pipeline().addLast(new PacketDecoder(), handler);
}
}
代码示例来源:origin: dremio/dremio-oss
@Override
public void run() {
try {
closeLatch.await();
((RemoteConnection)connection).getChannel().close();
} catch (InterruptedException e) {
}
}
代码示例来源:origin: kompics/kompics
futures.add(c.close());
} catch (Exception ex) {
component.extLog.warn("Error during Netty shutdown. Messages might have been lost! \n {}", ex);
代码示例来源:origin: org.apache.sshd/sshd-netty
listener.connectionEstablished(NettyIoConnector.this, local, remote);
} catch (Exception e) {
ch.close();
throw e;
代码示例来源:origin: org.projectreactor/reactor-tcp
@Override
public void close() {
super.close();
closing = true;
channel.disconnect().awaitUninterruptibly();
channel.close().awaitUninterruptibly();
}
代码示例来源:origin: org.apache.sshd/sshd-netty
listener.connectionAccepted(NettyIoAcceptor.this, local, remote);
} catch (Exception e) {
ch.close();
throw e;
代码示例来源: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.close();
代码示例来源:origin: org.opendaylight.openflowjava/openflow-protocol-impl
ch.close();
代码示例来源:origin: io.netty/netty-testsuite
ch.close();
代码示例来源: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();
}
}
代码示例来源:origin: dremio/dremio-oss
@Override
public void handle(final PhysicalConnection connection, int rpcType, ByteString pBody, ByteBuf dBody,
ResponseSender sender) throws RpcException {
switch(rpcType){
case 1:
sender.send(new Response(new FakeEnum(1), expectedD));
new Thread(){
@Override
public void run() {
try {
closeLatch.await();
((RemoteConnection)connection).getChannel().close();
} catch (InterruptedException e) {
}
}
}.start();
return;
case 2:
((RemoteConnection)connection).getChannel().close();
return;
default:
throw new UnsupportedOperationException();
}
}
内容来源于网络,如有侵权,请联系作者删除!