本文整理匯總了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));
}