本文整理汇总了Java中java.nio.channels.NetworkChannel.setOption方法的典型用法代码示例。如果您正苦于以下问题:Java NetworkChannel.setOption方法的具体用法?Java NetworkChannel.setOption怎么用?Java NetworkChannel.setOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.nio.channels.NetworkChannel
的用法示例。
在下文中一共展示了NetworkChannel.setOption方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setSocketParams
import java.nio.channels.NetworkChannel; //导入方法依赖的package包/类
public void setSocketParams(Connection con, boolean isFrontChannel) throws IOException {
int sorcvbuf = 0;
int sosndbuf = 0;
int soNoDelay = 0;
if (isFrontChannel) {
sorcvbuf = netConfig.getFrontsocketsorcvbuf();
sosndbuf = netConfig.getFrontsocketsosndbuf();
soNoDelay = netConfig.getFrontSocketNoDelay();
} else {
sorcvbuf = netConfig.getBacksocketsorcvbuf();
sosndbuf = netConfig.getBacksocketsosndbuf();
soNoDelay = netConfig.getBackSocketNoDelay();
}
NetworkChannel channel = con.getChannel();
channel.setOption(StandardSocketOptions.SO_RCVBUF, sorcvbuf);
channel.setOption(StandardSocketOptions.SO_SNDBUF, sosndbuf);
channel.setOption(StandardSocketOptions.TCP_NODELAY, soNoDelay == 1);
channel.setOption(StandardSocketOptions.SO_REUSEADDR, true);
channel.setOption(StandardSocketOptions.SO_KEEPALIVE, true);
}
示例2: setSocketParams
import java.nio.channels.NetworkChannel; //导入方法依赖的package包/类
public void setSocketParams(Connection con, boolean isFrontChannel) throws IOException {
int sorcvbuf = 0;
int sosndbuf = 0;
int soNoDelay = 0;
if (isFrontChannel) {
sorcvbuf = netConfig.getFrontsocketsorcvbuf();
sosndbuf = netConfig.getFrontsocketsosndbuf();
soNoDelay = netConfig.getFrontSocketNoDelay();
} else {
sorcvbuf = netConfig.getBacksocketsorcvbuf();
sosndbuf = netConfig.getBacksocketsosndbuf();
soNoDelay = netConfig.getBackSocketNoDelay();
}
NetworkChannel channel = con.getChannel();
channel.setOption(StandardSocketOptions.SO_RCVBUF, sorcvbuf);
channel.setOption(StandardSocketOptions.SO_SNDBUF, sosndbuf);
channel.setOption(StandardSocketOptions.TCP_NODELAY, soNoDelay == 1);
channel.setOption(StandardSocketOptions.SO_REUSEADDR, true);
channel.setOption(StandardSocketOptions.SO_KEEPALIVE, true);
con.setMaxPacketSize(netConfig.getMaxPacketSize());
con.setPacketHeaderSize(netConfig.getPacketHeaderSize());
}
示例3: setSocketParams
import java.nio.channels.NetworkChannel; //导入方法依赖的package包/类
public void setSocketParams(AbstractConnection con, boolean isFrontChannel)
throws IOException {
int sorcvbuf = 0;
int sosndbuf = 0;
int soNoDelay = 0;
if ( isFrontChannel ) {
sorcvbuf = system.getFrontsocketsorcvbuf();
sosndbuf = system.getFrontsocketsosndbuf();
soNoDelay = system.getFrontSocketNoDelay();
} else {
sorcvbuf = system.getBacksocketsorcvbuf();
sosndbuf = system.getBacksocketsosndbuf();
soNoDelay = system.getBackSocketNoDelay();
}
NetworkChannel channel = con.getChannel();
channel.setOption(StandardSocketOptions.SO_RCVBUF, sorcvbuf);
channel.setOption(StandardSocketOptions.SO_SNDBUF, sosndbuf);
channel.setOption(StandardSocketOptions.TCP_NODELAY, soNoDelay == 1);
channel.setOption(StandardSocketOptions.SO_REUSEADDR, true);
channel.setOption(StandardSocketOptions.SO_KEEPALIVE, true);
con.setMaxPacketSize(system.getMaxPacketSize());
con.setPacketHeaderSize(system.getPacketHeaderSize());
con.setIdleTimeout(system.getIdleTimeout());
con.setCharset(system.getCharset());
}
示例4: make
import java.nio.channels.NetworkChannel; //导入方法依赖的package包/类
public FrontendConnection make(NetworkChannel channel) throws IOException {
channel.setOption(StandardSocketOptions.SO_REUSEADDR, true);
channel.setOption(StandardSocketOptions.SO_KEEPALIVE, true);
FrontendConnection c = getConnection(channel);
MycatServer.getInstance().getConfig().setSocketParams(c, true);
return c;
}
示例5: make
import java.nio.channels.NetworkChannel; //导入方法依赖的package包/类
public FrontendConnection make(NetworkChannel channel) throws IOException {
channel.setOption(StandardSocketOptions.SO_REUSEADDR, true);
channel.setOption(StandardSocketOptions.SO_KEEPALIVE, true);
FrontendConnection c = getConnection(channel);
c.setSocketParams(true);
return c;
}
示例6: setChannelOptions
import java.nio.channels.NetworkChannel; //导入方法依赖的package包/类
private void setChannelOptions(final NetworkChannel channel) throws IOException {
channel.setOption(StandardSocketOptions.SO_RCVBUF, PeerConnectionController.SO_RCVBUF_VALUE);
}