php/c++ - PHP 和 C 之间通信的最佳方法客户端(REST、套接字等)
假设我有一个用 PHP 编写的网站。用户从网站下载 C++ 控制台程序并将其安装在计算机上。现在,我希望能够将 printf() 字符串从我的 PHP 网站(服务器)打印到 C++ 控制台程序(客户端)。我想过通过提供 XML 文件来使用 REST,例如:
<prints> <print>Text</print> </prints>
REST 的优点是它易于使用。缺点是C++程序必须不断下载XML文件。如果用户的互联网使用受到限制,这会是一个问题吗?
另一种解决方案是套接字,它可以消除上述问题,但是它们更复杂,并且可能会被防火墙/路由器阻止。
我的问题是:如果用户的互联网使用受到限制,从 Web 服务器下载 XML 文件是否会产生问题?另外,REST 和套接字之间是否存在折衷方案,或者是否有这种类型的通信的替代方案?
Let's say I have a website written in PHP. A user downloads a C++ console program from the website and installs it on their computer. Now, I want to be able to printf() strings from my PHP website (the server) to the C++ console programs (the clients). I have thought of using REST by serving XML file such as:
<prints> <print>Text</print> </prints>
The advantage of REST is it's ease of use. The disadvantage is the C++ program has to constantly download the XML file. Would this be a problem if the user has a limit on their internet usage?
Another solution is sockets which eliminate the issue above, but, they are more complicated and they may be blocked by firewalls/routers.
My question is: Will downloading the XML file from the web server create a problem if the user has a limit on their internet usage? Also, is there a compromise between REST and sockets or is there an alternative to this type of communication?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
HTTP 是用于访问网站的协议。
HTTP is a protocol used to access websites.