我可以使用 GenericServlet 在 Tomcat 上实现套接字服务器吗?

编程入门 行业动态 更新时间:2024-10-26 12:23:19
本文介绍了我可以使用 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 上实现套接字服务器吗?

本文发布于:2023-08-07 13:41:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1319358.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:可以使用   服务器   GenericServlet   Tomcat

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!