客户端到客户端的连接?

发布于 2024-12-22 19:29:20 字数 132 浏览 2 评论 0原文

我使用 C 和 Winsock 库 (UDP) 制作了一个客户端-服务器多人游戏。

现在我想让客户端可以直接相互连接(例如,在《魔兽争霸 III》中,当某人主持游戏时,其他玩家直接连接到他),但我不知道也无法找到有关如何操作的信息这。

Using C and the Winsock library (UDP), I made a client-server multiplayer game.

Now I would like to make it so clients can be connected directly to each other (for example in Warcraft III when someone hosts a game the other players connect directly to him), but I do not know and could not find information on how to do this.

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

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

发布评论

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

评论(1

断肠人 2024-12-29 19:29:20

在大多数情况下 - 特别是在当今不幸的世界中,大多数客户端都位于 NAT 防火墙和 ISP 后面,这些防火墙和 ISP 会阻止如此多的传入连接 - 客户端/服务器程序(例如您想要做的事情)将通过中央服务器路由所有流量,这是“保证”所有客户都可以访问。

否则,您需要研究 UPnP 和/或类似 UDP 打洞,以实现可能位于上述约束后面的客户端之间的访问。

For the most part - especially in today's unfortunate world where most clients are behind NAT firewalls and ISPs that block so many incoming connections - client/server programs such as what you're looking to do will route all traffic through the central server, which is "guaranteed" to be accessible from all clients.

Otherwise, you'll want to look into UPnP, and/or something like UDP hole punching to achieve access between clients that may be behind the constraints listed above.

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