强制 MINA niosocketacceptor 清理
我开始使用 mina 对套接字进行异步写入,但现在我似乎无法关闭会话。有没有办法强制 mina 关闭所有托管会话或进行清理?这就是我现在要清洁的东西:
if(this.acceptor.isActive()) {
for(IoSession session : this.acceptor.getManagedSessions().values()) {
session.close(true);
}
this.acceptor.unbind();
this.acceptor.dispose();
}
谢谢
I started to using mina to do async writes to the socket, but now I can't seem to close the sessions. Is there a way to force mina to close all the managed sessions or clean up? There what i have for the clean right now:
if(this.acceptor.isActive()) {
for(IoSession session : this.acceptor.getManagedSessions().values()) {
session.close(true);
}
this.acceptor.unbind();
this.acceptor.dispose();
}
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你把这段代码放在哪里了?
我只是使用了如下所示的 for 循环,并且所有会话都已关闭。首先,运行服务器并在 10 秒内启动 3 个客户端。您将看到所有客户端的会话将在 10 秒后关闭。
Where did you put that code?
I just used for loop like below and all sessions were closed. First, run the server and start 3 clients in 10 seconds. You will see all clients' sessions will be closed when 10 secs is up.