0

I'm running webserver on Raspberry PI, and I'm planning to set multiple PI's on different locations. Those PI's will communicate with webserver via TCP connection (webserver will send them data that users enter (data will be different for each PI, PI's will send back log files). The biggest problem now is, which device should be client and which should be server?

I was thinking about every PI being a TCP server, with webserver being a TCP client. Webserver will then connect to PI's TCP server, send him data and PI will answer with log files. Is this good way to solve my problem?

  • Why are you talking about TCP and a Webserver ? If you are using Layer 5 protocols (HTTP) , stay with them. What is your high-level architecture ? REST ? – flakeshake May 2 '16 at 8:09
1

You're overcomplicating things if you put a 'server' on each pi.

Depending on the project the pi's might not be accessable/powered etc and so you'll have no way of having a user 'enter' the data at the time.

If I was you I'd have a central server which holds whatever data users have entered. As for which is the tcp 'server' and 'client' this doesn't matter, nor make sense. TCP doesn't have an understanding of servers and clients, it simply transports data from A to B and possibly from B -> A. In the first one, A is the 'server', and in the second one 'B' is the server.

If you can share more information on what you're planning then obviously this might cause the answer to change accordingly.

  • 1
    PI's and server will be up 24/7, so that shouldn't be a problem. Well with 'server' I was thinking about the device having TCP connection 'up' all the time, listening for connections. – Rok Dolinar Feb 1 '16 at 23:52
  • Have a look at MQTT or ZeroMQ. Webservers don't use plain TCP , but HTTP. – flakeshake Oct 5 '16 at 10:21
1

Normally, the side waiting for incoming requests should be the server, and the side which actively initiates connections should be the client.

However, it's entirely possible to have one central server (you web server) waiting for clients and distributing them data when they connect. This will require your clients to periodically connect to the server to check for new data. This will effectively achieve the same communication scheme as if you ran servers on every Pi which waited for orders from the central device, without the need to configure so many servers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.