本文整理了Java中io.netty.channel.socket.SocketChannel.config()
方法的一些代码示例,展示了SocketChannel.config()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SocketChannel.config()
方法的具体详情如下:
包路径:io.netty.channel.socket.SocketChannel
类名称:SocketChannel
方法名:config
暂无
代码示例来源:origin: spring-projects/spring-framework
@Override
protected void initChannel(SocketChannel channel) throws Exception {
configureChannel(channel.config());
ChannelPipeline pipeline = channel.pipeline();
if (isSecure) {
Assert.notNull(sslContext, "sslContext should not be null");
pipeline.addLast(sslContext.newHandler(channel.alloc(), uri.getHost(), uri.getPort()));
}
pipeline.addLast(new HttpClientCodec());
pipeline.addLast(new HttpObjectAggregator(maxResponseSize));
if (readTimeout > 0) {
pipeline.addLast(new ReadTimeoutHandler(readTimeout,
TimeUnit.MILLISECONDS));
}
}
});
代码示例来源:origin: org.springframework/spring-web
@Override
protected void initChannel(SocketChannel channel) throws Exception {
configureChannel(channel.config());
ChannelPipeline pipeline = channel.pipeline();
if (isSecure) {
Assert.notNull(sslContext, "sslContext should not be null");
pipeline.addLast(sslContext.newHandler(channel.alloc(), uri.getHost(), uri.getPort()));
}
pipeline.addLast(new HttpClientCodec());
pipeline.addLast(new HttpObjectAggregator(maxResponseSize));
if (readTimeout > 0) {
pipeline.addLast(new ReadTimeoutHandler(readTimeout,
TimeUnit.MILLISECONDS));
}
}
});
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
protected void initChannel(SocketChannel c) {
MessageHandler handler = new MessageHandler(connectionManager);
CodecsHandler codecs = new CodecsHandler(ProtocolType.HANDSHAKE.getProtocol());
FramingHandler framing = new FramingHandler();
try {
c.config().setOption(ChannelOption.IP_TOS, 0x18);
} catch (ChannelException e) {
// Not supported on all OSs, like Windows XP and lesser
GlowServer.logger.warning("Your OS does not support type of service.");
}
c.pipeline()
.addLast("idle_timeout", new IdleStateHandler(READ_IDLE_TIMEOUT, WRITE_IDLE_TIMEOUT, 0))
.addLast("legacy_ping", new LegacyPingHandler(connectionManager))
.addLast("encryption", NoopHandler.INSTANCE)
.addLast("framing", framing)
.addLast("compression", NoopHandler.INSTANCE)
.addLast("codecs", codecs)
.addLast("handler", handler);
}
}
代码示例来源:origin: foxinmy/weixin4j
@Override
protected void initChannel(SocketChannel channel)
throws Exception {
ChannelPipeline pipeline = channel.pipeline();
if (params != null) {
channel.config().setConnectTimeoutMillis(
params.getConnectTimeout());
if (options != null) {
channel.config().setOptions(options);
}
pipeline.addLast(new ReadTimeoutHandler(params
.getReadTimeout(),
TimeUnit.MILLISECONDS));
}
pipeline.addLast(new HttpClientCodec());
pipeline.addLast(new HttpContentDecompressor());
pipeline.addLast(new ChunkedWriteHandler());
pipeline.addLast(new HttpResponseDecoder());
pipeline.addLast(new HttpObjectAggregator(
Integer.MAX_VALUE));
}
});
代码示例来源:origin: aadnk/ProtocolLib
@Override
public boolean getKeepAlive() throws SocketException {
return ch.config().getOption(ChannelOption.SO_KEEPALIVE);
}
代码示例来源:origin: aadnk/ProtocolLib
@Override
public int getTrafficClass() throws SocketException {
return ch.config().getOption(ChannelOption.IP_TOS);
}
代码示例来源:origin: aadnk/ProtocolLib
@Override
public void setReuseAddress(boolean on) throws SocketException {
ch.config().setOption(ChannelOption.SO_REUSEADDR, on);
}
代码示例来源:origin: aadnk/ProtocolLib
@Override
public synchronized int getReceiveBufferSize() throws SocketException {
return ch.config().getOption(ChannelOption.SO_RCVBUF);
}
代码示例来源:origin: aadnk/ProtocolLib
@Override
public boolean getReuseAddress() throws SocketException {
return ch.config().getOption(ChannelOption.SO_REUSEADDR);
}
代码示例来源:origin: aadnk/ProtocolLib
@Override
public int getSoLinger() throws SocketException {
return ch.config().getOption(ChannelOption.SO_LINGER);
}
代码示例来源:origin: aadnk/ProtocolLib
@Override
public boolean getTcpNoDelay() throws SocketException {
return ch.config().getOption(ChannelOption.TCP_NODELAY);
}
代码示例来源:origin: aadnk/ProtocolLib
@Override
public void setSoLinger(boolean on, int linger) throws SocketException {
ch.config().setOption(ChannelOption.SO_LINGER, linger);
}
代码示例来源:origin: aadnk/ProtocolLib
@Override
public void setKeepAlive(boolean on) throws SocketException {
ch.config().setOption(ChannelOption.SO_KEEPALIVE, on);
}
代码示例来源:origin: dremio/dremio-oss
public void setAutoRead(boolean enableAutoRead) {
channel.config().setAutoRead(enableAutoRead);
}
代码示例来源:origin: com.hazelcast.simulator/simulator
@Override
public void initChannel(SocketChannel channel) {
channel.config().setReuseAddress(true);
configureServerPipeline(channel.pipeline(), AbstractServerConnector.this);
}
});
代码示例来源:origin: org.neo4j/neo4j-bolt-transport-socket
@Override
public void initChannel( SocketChannel ch ) throws Exception
{
ch.config().setAllocator( PooledByteBufAllocator.DEFAULT );
if( sslCtx != null )
{
ch.pipeline().addLast( sslCtx.newHandler( ch.alloc() ) );
}
ch.pipeline().addLast( new SocketTransportHandler(
new SocketTransportHandler.ProtocolChooser( protocolVersions ), logging ) );
}
} );
代码示例来源:origin: aerospike/aerospike-client-java
private final void putConnection() {
conn.channel.config().setAutoRead(false);
InboundHandler handler = (InboundHandler)conn.channel.pipeline().last();
handler.command = null;
conn.updateLastUsed();
command.node.putAsyncConnection(conn, eventState.index);
}
代码示例来源:origin: io.netty/netty-testsuite
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
SocketChannel childChannel = (SocketChannel) msg;
childChannel.config().setSoLinger(0);
childChannel.unsafe().closeForcibly();
}
}).childHandler(new ChannelInboundHandlerAdapter());
代码示例来源:origin: com.aerospike/aerospike-client
private final void putConnection() {
conn.channel.config().setAutoRead(false);
InboundHandler handler = (InboundHandler)conn.channel.pipeline().last();
handler.command = null;
conn.updateLastUsed();
command.node.putAsyncConnection(conn, eventState.index);
}
代码示例来源:origin: aadnk/ProtocolLib
@Override
public void connect(SocketAddress endpoint, int timeout) throws IOException {
ch.config().setConnectTimeoutMillis(timeout);
ch.connect(endpoint).syncUninterruptibly();
}
内容来源于网络,如有侵权,请联系作者删除!