Network UDP TCP Sockets
A few illustrated reminds about UDP TCP sockets.
For complete explanations, please have a look at : https://www.enib.fr/~harrouet
Every following examples can be downloaded here :
CODE
just write ‘make’ in a terminal to compile all of them.
IP address
UDP text
Considering we have a Linux PC + another Linux PC or Rasperry PI :

If you want to test with one PC ( with local adress 127.0.0.1) , consider this drawing :

UDP bin
Datas are not necessarly characters ; sending binary datas supposes knowing byte order.
That’s the purpose of htonl and ntohs functions.
UDP Select server
Since the receive function is blocking, the SELECT function permits switching between several incoming sources.

TCP mono server
TCP is a CONNECTED protocole, so before sending and receiving datas, the server must accept a client connection request.
For the moment the actual client must end the connection before the server accepts a new client.

TCP Select server
The Select Function permits switching between several sockets and listening for new TCP connections.


TCP Thread server
A more flexible server than the ‘select’ one : allowing a thread for each client.
The FOR loop in the main() wait on new connection requests.


