我可以使用 GenericServlet 在 Tomcat 上实现套接字服务器吗? [英] Can I implement a socket server on Tomcat using GenericServlet?

查看:33
本文介绍了我可以使用 GenericServlet 在 Tomcat 上实现套接字服务器吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现一个由多个客户端连接的套接字服务器.为了使实现尽可能简单并且不必编写线程和连接等的代码管理,我想使用 Tomcat.我们已经在解决方案中使用了 tomcat.

I would like to implement a socket server that will be connected to by multiple clients. In order to make the implementation as simple as possible and not have to code management of threads and connections etc I'd like to use Tomcat. We already use tomcat as part of our solution.

我确信 Tomcat 可用于非 http servlet 和套接字连接 - 使用 GenericServlet.我希望得到确认,并希望提供有关实现的任何提示.

I am sure that Tomcat can be used for non http servlets and socket connections - with GenericServlet. I'd like this to be confirmed and any tips that can be given about implementations.

更新 - 使用 tomcat 似乎是错误的策略 - 从其余的 tomcat 基础设施中获得的很少.有人有其他实施建议吗?例如,已推荐 Apache MINA - 还有其他的吗?

UPDATE - using tomcat seems the wrong tactic - little is gained from the rest of tomcat infrastructure. Anyone got other implementation suggestions? For example Apache MINA has been recommended - any others?

推荐答案

如果您想在 tomcat 中创建对非 HTTP 服务器的支持,您将需要实现一个新的协议处理程序(请参阅 PoolTcpEndpoint).但到那时,您将主要获得 Catalina 启动和关闭功能,而不是其他很多.

If you want to create support for a non-HTTP server inside tomcat you will need to implement a new protocol handler (see the docs for PoolTcpEndpoint). But at that point you're mostly going to be gaining the Catalina startup and shutdown functionality and not a whole lot else.

如果您确实希望将您的应用程序基于 servlet 容器,我建议使用 jetty,因为它的大小、易用性、以编程方式启动的能力以及完全适合调试器的能力.

If you do want to base your app on a servlet container, I'd suggest jetty for size, ease of use, ability to start programatically and ability to fit completely inside the debugger.

这篇关于我可以使用 GenericServlet 在 Tomcat 上实现套接字服务器吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆