当前位置: 首页>>代码示例>>Java>>正文


Java NetworkChannel.setOption方法代码示例

本文整理汇总了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);
}
 
开发者ID:variflight,项目名称:feeyo-redisproxy,代码行数:21,代码来源:NetSystem.java

示例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());

}
 
开发者ID:MyCATApache,项目名称:Mycat-NIO,代码行数:25,代码来源:NetSystem.java

示例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());

}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:30,代码来源:MycatConfig.java

示例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;
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:9,代码来源:FrontendConnectionFactory.java

示例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;
}
 
开发者ID:actiontech,项目名称:dble,代码行数:9,代码来源:FrontendConnectionFactory.java

示例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);
}
 
开发者ID:veroslav,项目名称:jfx-torrent,代码行数:4,代码来源:PeerConnectionController.java


注:本文中的java.nio.channels.NetworkChannel.setOption方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。