Flash 问答游戏与 "php & http请求” VS“套接字服务器”

发布于 2024-08-06 04:24:56 字数 96 浏览 3 评论 0 原文

我想构建一个带有房间和聊天功能的问答游戏。是否可以仅使用 PHP 和 HTTP 请求来实现?根据您的经验,它能容纳多少游客。我知道使用套接字服务器更好,但我现在只有一个共享主机。

I want to build a question/answer game with rooms and chat. Is it possible to make it with just PHP and HTTP requests? From you're experience, how many visitors will it hold. I know it's better with socket server but I only have a shared host right now.

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

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

发布评论

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

评论(1

谁对谁错谁最难过 2024-08-13 04:24:56

当然,仅使用 PHP+HTTP 就可以实现。不过,如果有新的聊天或游戏动作,您必须在 setInterval 上运行一个轮询器,以便通过 XMLHttpRequest 不断询问服务器。您可以支持多少用户取决于更新时间必须有多快;如果用户可以在轮询之间等待很多秒,那么您就不会有问题,但如果他们需要瞬间更新,则需要进行大量轮询,而您的共享服务器根本不够用。

对于任何实时响应式聊天或动作游戏,您需要自己的“套接字服务器”类型的安排,使用“Comet' 式的长轮询技术、Flash 套接字,或者将来的 HTML5 更方便的 WebSocket。

(无论如何,我都会考虑虚拟专用服务器;现在它们很便宜,并且共享 PHP 脚本服务器会让您在性能和安全性方面受到其他用户的摆布。)

Sure it's possible with only PHP+HTTP. You'd have to have a poller running on a setInterval to keep asking the server via XMLHttpRequest if there are new lines of chat or game moves, though. How many users you can support depends on how quick that update time must be; if users can wait many seconds between polls you won't have a problem, but if they need split-second updates that's a lot of polling and your shared server won't be sufficient at all.

For any realtime responsive chat or action games you would need your own ‘socket server’ type of arrangement, using ‘Comet’-style long-polling techniques, Flash sockets or, in the future, HTML5's much more convenient WebSocket.

(I'd look at virtual dedicated servers anyway; they're cheap these days and sharing a server for PHP scripts puts you at the mercy of other users for performance and security.)

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