本文整理汇总了Java中java.nio.channels.SelectableChannel.configureBlocking方法的典型用法代码示例。如果您正苦于以下问题:Java SelectableChannel.configureBlocking方法的具体用法?Java SelectableChannel.configureBlocking怎么用?Java SelectableChannel.configureBlocking使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.nio.channels.SelectableChannel
的用法示例。
在下文中一共展示了SelectableChannel.configureBlocking方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: register
import java.nio.channels.SelectableChannel; //导入方法依赖的package包/类
private void register(SelectableChannel channel, int ops, Handler callback) {
try {
channel.configureBlocking(false);
/*SelectionKey serverKey =*/ channel.register(selector, ops, callback);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例2: SocketIOWithTimeout
import java.nio.channels.SelectableChannel; //导入方法依赖的package包/类
SocketIOWithTimeout(SelectableChannel channel, long timeout)
throws IOException {
checkChannelValidity(channel);
this.channel = channel;
this.timeout = timeout;
// Set non-blocking
channel.configureBlocking(false);
}
示例3: registerChannel
import java.nio.channels.SelectableChannel; //导入方法依赖的package包/类
/**
* Register the given channel with the given selector for
* the given operations of interest
*/
protected void registerChannel(Selector selector,
SelectableChannel channel,
int ops,
Object attach) throws Exception {
if (channel == null)return; // could happen
// set the new channel non-blocking
channel.configureBlocking(false);
// register it with the selector
channel.register(selector, ops, attach);
}
示例4: makeBlocking
import java.nio.channels.SelectableChannel; //导入方法依赖的package包/类
/**
* Switch this guy to blocking mode so we can use oldIO to read and write msgs.
*/
public void makeBlocking() throws IOException {
// logger.info("DEBUG: makeBlocking " + this);
// if (this.sKey != null) {
// this.sKey = null;
// }
SelectableChannel c = this.theSocket.getChannel();
c.configureBlocking(true);
}
示例5: registerChannel
import java.nio.channels.SelectableChannel; //导入方法依赖的package包/类
/**
* Register the given channel with the given selector for the given
* operations of interest
*/
protected void registerChannel(Selector selector, SelectableChannel channel, int ops, Object attach)
throws Exception {
if (channel == null)
return; // could happen
// set the new channel non-blocking
channel.configureBlocking(false);
// register it with the selector
channel.register(selector, ops, attach);
}
示例6: init
import java.nio.channels.SelectableChannel; //导入方法依赖的package包/类
@Override
protected void init(NioSession session) throws Exception {
SelectableChannel ch = (SelectableChannel) session.getChannel();
ch.configureBlocking(false);
session.setSelectionKey(ch.register(selector, SelectionKey.OP_READ, session));
}