Want to keep learning?

This content is taken from the Raspberry Pi Foundation & National Centre for Computing Education's online course, Networking with Python: Socket Programming for Communication. Join the course to learn more.

Skip to 0 minutes and 2 secondsThe internet is a vast network containing many servers that provide services like web browsing or file transfers. When you connect to these services, your device is playing the role of a client. Clients make requests, and servers handle and respond to those requests. A server is a computer on a network that provides a resource that can be used by any authorised client station. In the client server model, servers are the boss. Servers hold the power and have the authority to grant or deny any request they get. You don't want the server to reject every request that comes in, but requests must be authorised. The level of access a server grants to any given client is an important security consideration.

Skip to 0 minutes and 46 secondsSometimes, the data on a server is designed to be open, and, therefore, the server will respond to requests from every client. But if the data is sensitive or commercially valuable, the server will need to ensure that the request is from a legitimate source. If not, it would risk exposing the data and potentially the network to malicious actors. Servers are usually always on and connected to the internet. This means that users can access their resources and services at any time. There are many types of server. Web servers store and provide the web pages we browse. This course is stored on a server. And every time you complete a step, your device will request the next one.

Skip to 1 minute and 27 secondsEmail servers direct email to the intended recipient and sometimes filter out spam. File transfer servers provide files to users, like those that provide the songs we listen to on Spotify. Many of these large internet services run on huge stacks of servers in massive warehouses. But you might also use a small personal server at home to store, share, or stream digital files. Companies might also run a server for their employees to share work or access video conferencing. A client is a computer or computer-controlled device that provides a user with access to a network. Clients are user-facing computers that run software to make requests to servers and interpret and display the responses.

Skip to 2 minutes and 11 secondsThey don't hold the power and can't force a server to respond to a request. If the server requires authentication that the client can't provide, the requested data will not be sent to the client. Clients don't always have to be on and should be able to start up and connect to a server anytime. Some clients have dedicated hardware devices with a single, specific function, whilst general purpose computers can be turned into clients by the software running on them. A lot of applications turn your smartphone into a client, not processing or computing much themselves, but instead making requests to servers to do it for them.

Skip to 2 minutes and 48 secondsThis model has granted immense computing power to mobile devices allowing them to perform a wider range of network tasks. What you will create over the next three weeks will demonstrate how servers and clients operate. However, this course won't show you how to create an entire server system. Real server systems are hugely complex and come with many security considerations. You will gain an understanding of how you can use the client and server model and the TCP/IP layers in your programs to facilitate communication. I don't recommend placing a server at home or at work without first ensuring it is secure and cannot be accessed from outside your network without authorization.

Skip to 3 minutes and 27 secondsThe programs you will create in this course will be designed to connect computers that are only on your network. I will point out where there are opportunities to open up and access it from elsewhere, but this is entirely at your own risk. Think of an internet resource or service that you use every day. What kind of client does it use? And what do you need to provide to authenticate yourself? Share your thoughts in the comments below.

The client/server model

I am now going to introduce you to another important model used in networking: the client/server model. The layered model I showed you in the last step guides communication across the internet; the client/server model describes how we make applications that use it.

Networked applications

The internet is a vast network containing many servers that provide services such as web browsing and file transfers. When you connect to these services, your device is playing the role of client. Clients make requests and servers handle and respond to those requests.

Servers

A server is a computer on a network that provides a resource that can be used by any authorised client station.

In the client/server model, servers are the boss. They hold the power and have the authority to grant or deny any request they get. Obviously you don’t want them to reject every request that comes in, but the inclusion of authorised in the definition is important.

The level of access a server grants to any given client is an important security consideration. Sometimes, the data on a server is designed to be open and so the server will respond to any request it receives (in this case, all clients are authorised). In other cases, the data may be sensitive or commercially valuable, in which case the server will need to ensure the request is from a legitimate source. If it did not, it would risk exposing the data, and potentially the network, to malicious actors.

Servers are usually always on and connected to the internet so that users can access their resources and services at any time. There are many types of server:

  • The most common type of server you will interact with is a web server; web servers store and provide the webpages we browse. This course is stored on a server; every time you complete a step, your device will request the next one.
  • Email servers direct email to the intended recipient and sometimes filter out spam.
  • File transfer servers provide files to users, like those that provide the songs we listen to on Spotify.

When thinking about servers, most people think of huge stacks in massive warehouses; while these are indeed what most of the large internet services mentioned run on, these are not the only servers that exist. People have personal servers in their homes, where they can store files and share them with others, or store media libraries and play them on speakers or televisions around their homes. Companies can also run servers for their employees, to access shared work or for video conferencing.

Clients

A client is a computer or computer-controlled device that provides a user with access to a network.

Clients are user-facing computers that run software to make requests to servers and interpret or display the responses. They do not hold the power, and cannot force a server to respond to a request. If the server requires authentication that the client cannot provide, the requested data will not be sent to the client.

Clients do not always have to be on, and should be able to start up and connect to a server at any time — this is why it is useful to have servers on all the time. Some clients are dedicated hardware devices, for example speed cameras. They capture photos and licence plate numbers and send a request to a central server to store and process them; that is their entire functionality. General-purpose computers can be turned into clients by the software running on them. A lot of applications turn your smartphone into a client, not processing or computing much itself but instead making requests to servers. This model has granted immense computing power to mobile devices, allowing them to perform a wider range of networked tasks.

The scope of this course

What you will create over the next three weeks will demonstrate how servers and clients operate. I want to be clear, however, that I do not have the scope to take you through creating an entire server system. “Real” server systems are hugely complex and come with many security considerations. What I want to demonstrate is how you can use the client/server model and the TCP/IP layers in your programs to facilitate communication.

I do not recommend placing a server at home or at work without first ensuring it is secure and cannot be accessed from outside your network without authorisation. To this end, the programs you will be creating in this course will be designed to connect computers that are on your network only. I will point out where there are opportunities to open it up and access it from elsewhere, but this is entirely at your own risk.

Clients in your life

Think of an internet resource or service you use every day.

What kind of client does it use? What do you need to provide to authenticate yourself?

Post your answers in the comments below.

Share this video:

This video is from the free online course:

Networking with Python: Socket Programming for Communication

Raspberry Pi Foundation