在 PC 上托管游戏 - UDP 或 UPNP 通信?

发布于 2024-12-17 00:33:57 字数 329 浏览 2 评论 0原文

我已经为我希望普通人使用的游戏构建了一个服务器应用程序。现在,由于我以前使用过客户端/服务器解决方案,所以我知道在某些计算机上托管连接是多么乏味。

所以,我听说了这些谣言,我想得到证实。

  1. 使用 UDP 来“托管”连接很好,因为与 TCP 相比,它很少被路由器防火墙阻止。

  2. 使用 UPNP 与路由器通信很好,因为它允许您为游戏添加端口转发,无论您使用 TCP 还是 UDP,都可以访问您的服务器。

我不关心人们可能使用的软件防火墙。我关心的是路由器防火墙功能。

任何帮助将不胜感激。

谢谢!

I've built a server-application for a game that I want general people to use. Now, since I've worked with client/server solutions before, I know how tedious it is to host connections on some computers.

So, I heard about these rumors that I would like to get confirmed.

  1. Using UDP for "hosting" a connection is good, because it is rarely blocked by router-firewalls compared to TCP.

  2. Using UPNP for communicating with a router is good, because it allows you to add port forwarding for the game, making your server reachable no matter if you're using TCP or UDP.

I don't care about the software-firewall people may use. What I care about is the router firewall functionality.

Any help would be appreciated.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

内心激荡 2024-12-24 00:33:57

对于你的两个谣言,

  1. 我不知道,我对防火墙的使用还不够,但我不会认为这是真的。大多数路由器会阻止所有内容(TCP 和 UDP),除非您明确要求它通过手动设置或 UPNP 转发入站连接。如果您不告诉路由器哪台计算机希望将信息传入端口 12345,那么当用户向其发送未经请求的数据包(服务器的定义)时,它如何知道要做什么。

  2. 是的,学习如何进行 UPNP 将使您的用户托管游戏变得更加容易,但是您仍然应该为未打开 UPNP 或其路由器不支持它的用户提供说明。

您可能想要了解的另一件事是学习如何将您的程序添加到 Windows 防火墙客户端允许列表中,因为这是大多数用户都会拥有的。有关更多详细信息,请参阅此问题

For your two rumors,

  1. I don't know, I have not worked with firewalls enough, but I would not call that one true. Most routers block everything (TCP and UDP) unless you explicitly ask it to forward it for inbound connections via hand setup or UPNP. If you don't tell the router what computer wants info coming in to port 12345 how will it know what to do when a user sends a unsolicited packet to it (the definition of being a server).

  2. Yes, learning how to do UPNP will make it a lot easier for your users to host games, however you should still provide instructions for people who do not have UPNP turned on or their router does not support it.

The other thing you may want to look in to is learning how to add your program to the windows firewall client allowed list as that is what most of your users will have. See this SO question for more details.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文