SocketAcceptor acceptor = new NioSocketAcceptor();
public NioSocketAcceptor() {
super(new DefaultSocketSessionConfig(), NioProcessor.class);
//初始化前面设置在AbstractIoService 中的 sessionConfig
((DefaultSocketSessionConfig) getSessionConfig()).init(this);
}
protected AbstractPollingIoAcceptor(IoSessionConfig sessionConfig,
Class<? extends IoProcessor<T>> processorClass) {
// new SimpleIoProcessorPool 新建 processor -- 处理线程
this(sessionConfig, null, new SimpleIoProcessorPool<T>(processorClass),
true);
}
//绑定端口
acceptor.bind(new InetSocketAddress(PORT));
AbstractIoAcceptor 的 public final void bind(Iterable<? extends SocketAddress> localAddresses) 方法中
boundAddresses.addAll(bindInternal(localAddressesCopy));
protected final Set<SocketAddress> bindInternal(
List<? extends SocketAddress> localAddresses) throws Exception {
// Create a bind request as a Future operation. When the selector
// have handled the registration, it will signal this future.
AcceptorOperationFuture request = new AcceptorOperationFuture(
localAddresses);
// adds the Registration request to the queue for the Workers
// to handle
//添加请求到注册列表
registerQueue.add(request);
// creates the Acceptor instance and has the local
// executor kick it off.
//开始用线程监听通道
startupAcceptor();
// As we just started the acceptor, we have to unblock the select()
// in order to process the bind request we just have added to the
// registerQueue.
wakeup();
// Now, we wait until this request is completed.
request.awaitUninterruptibly();
if (request.getException() != null) {
throw request.getException();
}
// Update the local addresses.
// setLocalAddresses() shouldn't be called from the worker thread
// because of deadlock.
Set<SocketAddress> newLocalAddresses = new HashSet<SocketAddress>();
for (H handle:boundHandles.values()) {
newLocalAddresses.add(localAddress(handle));
}
return newLocalAddresses;
}
startupAcceptor 中启动了一个 Acceptor 启动Socket服务
分享到:
相关推荐
mina-core-2.0.0-M6.jar mina-example-2.0.0-M6.jar mina-filter-codec-netty-2.0.0-M6.jar mina-filter-compression-2.0.0-M6.jar mina-integration-beans-2.0.0-M6.jar mina-integration-jmx-2.0.0-M6.jar mina-...
mina-core-2.0.0-RC1.jar,mina-filter-compression-2.0.0-RC1.jar,mina-transport-apr-2.0.0-RC1.jar
mina-filter-compression-2.0.7.jar,mina 过滤器jar包,核心包之一
mina-core-2.0.0-M1.jar/mina-example-1.0.5.jar/slf4j-jdk14-1.6.1.jar/slf4j-log4j12-1.6.1.jar mina 所用jar
mina-core-2.0.0-RC1-sources.jar
mina-core-2.0.0-M1-sources.jar是构建mina框架的主要文件
mina-integration-ognl-2.0.0-M4.jar mina-integration-ognl-2.0.0-M4.jar
mina-core-2.0.0-M1.jar包和slf4j相关jar包
mina-integration-beans-2.0.0-M4.jar mina-integration-beans-2.0.0-M4.jar
mina-transport-apr-2.0.2.jar
mina服务器--实现纯文本和非纯文本的加密通讯
mina-core-2.0.0-M6.jar
mina 最新 2.0 RC1 mina-core-2.0.0-RC1.jar mina-core-2.0.0-RC1-sources.jar
mina-filter-compression-2.0.2.jar
请与“MINA_Client_Test”一起使用,可运行
mina-core-2.0.0-RC1.jar
mina-integration-beans-2.0.2.jar
mina-integration-jmx-2.0.2.jar
mina-integration-xbean-2.0.2.jar
Java mina框架jar包, mina官网下载 mina-core-2.0.7.jar,正版 相关下载链接