Network sockets
The other socket address family that is widely used is AF_INET
. It simply refers to any channel established on top of a network connection. Unlike the UDS stream and datagram sockets, which have no protocol name assigned to them, there are two well-known protocols on top of network sockets. TCP sockets establish a stream channel between every two processes, and UDP sockets establish a datagram channel that can be used by a number of processes.
In the following sections, we are going to explain how to develop programs using TCP and UDP sockets and see real some examples as part of the calculator project.
TCP server
A program using a TCP socket to listen and accept a number of clients, in other words a TCP server, is different from a stream server listening on a UDS endpoint in two ways: firstly, it specifies a different address family, AF_INET
instead of AF_UNIX
, when calling the socket
function. And secondly, it uses a different structure for the...