7. Client and Server

Client-Server model

In computer science there is something called Client-Server model. Imagine that you have your own country and between the cities there is no route. Their only connection to the world is with the biggest city in this country called "Server". And if you want to travel from one city to another you have to go trough "Server". Respectively all the resources you can get from the other cities have to go trough "Server". And all the cities are named Client. In short the Client-Server model is a structure of connectivity between different devices trough network.


When we want to communicate from one device to another there must be some kind of connectiono between them. In our first module we have a direct communication between our phone and our Raspberry. And it goes trough bluethoot channel. So our two devices are connected. But if we want to send message to a person it goes a little bit more complicated.

Message to another person

How does we communicate to other people when they are far away? All the message services are based on Client-Server model. You and your recipient are the Clients. When you send a message it goes to the Server and Server send it to your friend. All chat services like Facebook Messenger, Google Hangouts,WeChat, Slack etc. are based on Clien-Server.

Can somebody read my messages ?

Theoretically No, but practically Yes. On theory there are many standarts, laws and declarations about safety of your messages, and there are for real many crypting and autenthication algorithms which protects your messages from attacks from hackers and other bad people. But practically there are governments and security sectors of countries which reads your messages. 

Is there any different model of communication that we can use ? 

Yes, it's called Peer-to-Peer(P2P). Let's back to the example with the country and cities in the beginning. If there is no central city called "Server" and every city is connected with all other cities, then we have peer-to-peer connection. In this model every client is and server too. It's hard to secure because, every peer have to secure his own files, like locking them with passwords. And every peer can provide and request files or resources. The bad thing about this model is that when there are many "peers" the connection between them goes too complicated. So we can say that this model is not so scalable and stable as the client-server model.

Why we need this in our course and how we will use it?

In this module we will want to make a game. Sometimes it's needed only one player, but in most cases there must be at least two players. For making the communication between two players will use the client-server model. The server will be based on our Raspberry and the two players will send their messages trough their phones.