简体   繁体   中英

Python Web Service vs Socket programming Client/Server Design

I need some help, i am on early design stage of a client server software and i don't know which of the 2 options (Web Service or Socket programming) are the right one for my software.

All programming is in python.

The layout: 在此处输入图片说明

  1. PC will need to run a server service - this server will get commands from the local computer and will send them to the MiniPC.

  2. MiniPC will need to run a client service - when it identify a command (method) he will go to hardware (connection by serial,usb.....), do something and return to the miniPC with result.

  3. MiniPC get the Hardware result and sends it to the Logging server and to the Main PC

Notes:

  • PC can controls several MiniPC.
  • The amount of data in one hardware response can be up to 10Kb.
  • Commands from PC to MiniPC are small (strings)
  • Logging data can be up to 10Kb.

Questios:

  1. What is you recomendation for protocol Web (http) or Socket programming?
  2. Do you have any suggestions for the design?

You should be able to use socket programming for this. Setup a socket server at the PC and a client at MiniPC devices. The clients would wait for input (read from socket) from the PC and then send back the output that they would get back from hardware. In terms of design, I see two things. First, the socket server can run a select() to handle multiple clients. Second, you probably want to bump up the SO_SNDBUF socket option for MiniPC sockets and SO_RCVBUF for the server at PC to multiples of 10Kb. What is your argument for considering Web?

I'have done a similar project with ARM-based controllers instead on BeagleBone : feel free to ask me questions by commentaries.

Firstly, technically your BeagleBones are servers - since they ran a daemon service which is event triggered - and PC are clients. (but it is just pendantry)

Secondly, due to the limitations of embedded devices, I was not able to have an efficient Web server running on servers, so the choice was simple. I would advise you to stick with socket programming, but adding network services such as DCHP , support of TCP/UDP/UDP multicast, ping, echo, ...

Finally, the important question in terms of performance is the following : what's the physical layer of communication ? Ethernet ? Wifi ? Bluetooth/ZigBee ? I2C/CAN/... ?

I will guess it's Ethernet : IEEE 802.11 protocol doesn't scale well because of CSMA ( see here http://fr.wikipedia.org/wiki/CSMA ). If you want to have several devices (dozens), you will need switches/routers to encapsulate sub-networks to avoid network congestion.

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