Loading s7nsa_04_sockets...

enib_small.png S7-NSA 04_sockets — Socket programming

The purpose of this tutorial is to introduce the fundamentals of using programming techniques to develop applications that communicate over a network.
For educational reasons, the examples will be implemented using the low-level features of the Python language.
The principles involved are the same with other programming languages and form the essential foundation of higher-level libraries that conceal the underlying details.

As each tutorial is independent, it is recommended that you create a separate directory on your workstation in which to save your work for this tutorial.
This will allow you to retrieve the state of your work on each tutorial you have completed.

Do not hesitate to use any external help available, including your favourite LLM, to obtain explanations.
Of course, the session supervisor is here to help in any case.

You are strongly encouraged to take notes during your observations so that you can review them before the quizzes.
{1 #env } Execution environment
{2 #udp_server } UDP server
{3 #udp_client } UDP client
{4 #tcp_server } TCP server
{5 #tcp_client } TCP client

You have now implemented the fundamental communication mechanisms that allow programs to communicate using the UDP and TCP protocols.
This has provided an opportunity to discover some of their properties.
In general, servers are explicitly bound to a chosen port number, whereas clients are automatically bound to an arbitrary port.
The UDP protocol can be understood using the analogy of the postal service:
The TCP protocol can be understood using the analogy of a telephone conversation:

Make sure you review your understanding of what has been covered so far so that you can approach the quizzes with confidence.
Some examples of possible questions