So, guys, let us start with our first method of establishing Interprocess communication and we will
going to study Unix domain socket in this section of the course.
So Unix domain sockets are used for carrying out inter-process communication between two processes which
are running on the same machine.
So note the word.
Whenever we say inter-process communication, by default we mean the inter-process communication between
the two processes running on the same machine.
We shall discuss the implementation of Unix domain socket with respect to server and client process.
So remember the two communicating processes are classified as server process and client process.
So server process is a process which actually waits for the request from the client process.
It is the responsibility of the client process to actually send the computation request to the server
process and it is the responsibility of the server process to process the client request and send back
the result back to the client.
So always remember the two.
Communicating processes can always be classified as server and client processes.
Using Unix domain sockets, we can set up either a stream based communication or datagram based communication.
Now let us see that.
What is the difference between stream and datagram based communication?
A stream based communication is a communication in which the two communicating processes actually involve
in continuous exchange of data in the form of bytes.
So, for example, it will be an example of a stream based communication when large files need to be
moved or copied from one location to another.
Right?
So for example, copying a movie from one location of your hard drive to another location.
So stream based communication is analogous to like flow of a water in a stream based communication.
There is continuous flow of bytes from the sending process to the receiving process.
Contrary to this, the other type of communication is a datagram based communication.
In datagram based communication is small.
Units of data needs to be moved from one process to another process within the system.
So in Datagram based communication, the sending process actually sends the chunk of data or you can
say the chunk of bytes of data to a receiving process.
There is absolutely no continuous flow of bytes.
Data is sent from the sending process to the receiving process in small, small individual units called
datagrams.
Now, next, let us discuss the steps involved in creating a socket based communication on a server
process.
So next we will going to discuss the implementation details regarding implementing Unix domain socket
based communication on the server process.
So you can see here listed is the steps for implementing socket based communication for server process.
So we will discuss the code and we will discuss each of these steps.
In a given sequence and try to understand that how you can implement Unix domain socket to create a
server process.
So on the right hand side, you can see the diagram which explains or capture the flowchart or steps
to implement a socket programming based communication between the server and the client process.
So you can see we have a server process here and the first step that the server process needs to do
is to create a socket which is also called as master socket file descriptor or connection socket.
The next step is the bind system call.
In the next step the server needs to do bind followed by listen and then the server has to call the
accept in order to wait for the connection from the new client.
Right.
And once the client connection request arrives using connect system call, you can see that the server
process is unblocked from the accept system call.
And then after that a server and the client process are actually engaged in the communication that is
exchanging the data.
So we will go through the code walk of implementing a server process and we will see that how each of
these steps are implemented using Unix domain sockets.
So let's start.