简体   繁体   中英

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

I can think of three ways

  1. Put the message kind in the header (next to the message size, probably)
  2. Use different sockets for each message kind (ugly and complicated but works)
  3. Use some sort of pub-sub eg Kafka, ZeroMQ or RabbitMQ to convey topics

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM