客户端到客户端的连接?
我使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在大多数情况下 - 特别是在当今不幸的世界中,大多数客户端都位于 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.