Web 服务或套接字级通信
我正在开发一个实时系统,我使用 IOS 设备来控制硬件。在硬件方面,我有一台 Windows PC。我将从 ios 设备发送命令到硬件,并且可以自由使用我认为合适的任何通信堆栈。您是否建议使用 Web 服务 (JSON/HTTP) 或低级套接字通信。网络性能不是问题,但由于遥测数据是来回发送的,因此我正在考虑使用 telnet 类型协议。想法?
I'm working on a realtime system where I'm using an IOS device to control a piece of hardware. On the hardware side I have a Windows PC. I will be sending commands from the ios device to the hardware and I'm free to use whatever communication stack I see fit. Would you recommend using web serivces (JSON/HTTP) or low level socket communications. Networks performance is not an issue, but since telemetry is being send back and forth I was considering using a telnet type protocol. Thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Telnet 类型意味着终端转换 - 我相信你的意思是原始套接字通信。
如果您进行双向通信,HTTP 并不理想。另外,如果你经常发出请求或更新数据,HTTP(非keep-alive)也不是理想的选择。
原始套接字是个好主意。协议仍然可以是 JSON(为了易于使用/可调试)。例如,可以发送 JSON 字符串 - 每个
\n
(换行符)字符,甚至每个\0
NULL 字符一个数据负载。Telnet type implies terminal conversion - I believe what you mean is raw socket communication.
If you are communicating bi-directionally, HTTP is not ideal. In addition, if you are frequently making requests or updating data, HTTP (in non-keep-alive) is not ideal either.
A raw socket is a great idea. The protocol can still be JSON (for ease of use/debugability). For instance, a JSON string can be sent - one data payload per
\n
(newline) character, or even per\0
NULL character.