python - send data with categories from client to a server using python
问题描述
I have an embedded system that monitors many sensors (GPS, Motor Speed, Temperature..)
I set up a client-server using sockets in python and I can send from the client(the embedded system) to the server(a Laptop) a string message like " Hello from client ".
But for me it would be great to send data with predifined categories so the server knows the type of the message. Upon reception the server knows it has recieved for example a GPS coordinate or motor speed.
Is there a way to do it in TCP or using any library or framework?
Thank you
解决方案
我能想到三种方法
- 将消息类型放在标题中(可能在消息大小旁边)
- 为每种消息类型使用不同的套接字(丑陋而复杂但有效)
- 使用某种 pub-sub 例如 Kafka、ZeroMQ 或 RabbitMQ 来传达主题
推荐阅读
- node.js - 如何将上传的文件保存在节点 js docker 容器之外(即在 linux 主机内部)?
- javascript - popper.js:边界元素和 escapeWithReference 不能一起工作?
- c - C语言读写二进制文件
- java - 用java读取混合数据的文件
- extjs6-classic - 如何在面板 Ext js 中对齐 html 文本
- c++ - 为什么你不应该`std::move(*const_cast
(ele))`std::initializer_list` 的元素? - types - 如何从usize中减去isize?
- c# - 是否可以订阅 IObservable
用一种方法? - javascript - 开发服务器返回响应错误码:500 react-native
- python - 基于 LSTM 的文本生成器的理想验证准确度应该是多少?