WEBVTT

00:04.960 --> 00:12.100
So, guys, let us start with our first method of establishing Interprocess communication and we will

00:12.100 --> 00:16.090
going to study Unix domain socket in this section of the course.

00:16.540 --> 00:23.020
So Unix domain sockets are used for carrying out inter-process communication between two processes which

00:23.020 --> 00:24.810
are running on the same machine.

00:24.880 --> 00:25.990
So note the word.

00:25.990 --> 00:32.560
Whenever we say inter-process communication, by default we mean the inter-process communication between

00:32.560 --> 00:35.590
the two processes running on the same machine.

00:35.890 --> 00:42.770
We shall discuss the implementation of Unix domain socket with respect to server and client process.

00:42.790 --> 00:50.090
So remember the two communicating processes are classified as server process and client process.

00:50.110 --> 00:55.960
So server process is a process which actually waits for the request from the client process.

00:55.990 --> 01:03.250
It is the responsibility of the client process to actually send the computation request to the server

01:03.250 --> 01:10.850
process and it is the responsibility of the server process to process the client request and send back

01:10.850 --> 01:12.650
the result back to the client.

01:12.980 --> 01:14.810
So always remember the two.

01:14.810 --> 01:20.210
Communicating processes can always be classified as server and client processes.

01:20.210 --> 01:27.550
Using Unix domain sockets, we can set up either a stream based communication or datagram based communication.

01:27.560 --> 01:28.910
Now let us see that.

01:28.910 --> 01:33.620
What is the difference between stream and datagram based communication?

01:34.370 --> 01:41.030
A stream based communication is a communication in which the two communicating processes actually involve

01:41.030 --> 01:46.340
in continuous exchange of data in the form of bytes.

01:46.910 --> 01:53.720
So, for example, it will be an example of a stream based communication when large files need to be

01:53.720 --> 01:56.690
moved or copied from one location to another.

01:56.690 --> 01:57.380
Right?

01:57.380 --> 02:03.110
So for example, copying a movie from one location of your hard drive to another location.

02:03.500 --> 02:10.460
So stream based communication is analogous to like flow of a water in a stream based communication.

02:10.460 --> 02:15.830
There is continuous flow of bytes from the sending process to the receiving process.

02:16.250 --> 02:21.170
Contrary to this, the other type of communication is a datagram based communication.

02:21.590 --> 02:24.470
In datagram based communication is small.

02:24.470 --> 02:30.650
Units of data needs to be moved from one process to another process within the system.

02:30.800 --> 02:37.670
So in Datagram based communication, the sending process actually sends the chunk of data or you can

02:37.670 --> 02:41.630
say the chunk of bytes of data to a receiving process.

02:43.140 --> 02:46.740
There is absolutely no continuous flow of bytes.

02:47.730 --> 02:54.570
Data is sent from the sending process to the receiving process in small, small individual units called

02:54.570 --> 02:55.770
datagrams.

02:56.190 --> 03:02.580
Now, next, let us discuss the steps involved in creating a socket based communication on a server

03:02.580 --> 03:03.570
process.

03:04.380 --> 03:11.070
So next we will going to discuss the implementation details regarding implementing Unix domain socket

03:11.070 --> 03:14.130
based communication on the server process.

03:14.250 --> 03:22.290
So you can see here listed is the steps for implementing socket based communication for server process.

03:22.500 --> 03:27.390
So we will discuss the code and we will discuss each of these steps.

03:27.990 --> 03:38.070
In a given sequence and try to understand that how you can implement Unix domain socket to create a

03:38.070 --> 03:39.390
server process.

03:39.690 --> 03:46.650
So on the right hand side, you can see the diagram which explains or capture the flowchart or steps

03:46.650 --> 03:54.080
to implement a socket programming based communication between the server and the client process.

03:54.090 --> 04:00.750
So you can see we have a server process here and the first step that the server process needs to do

04:00.750 --> 04:07.050
is to create a socket which is also called as master socket file descriptor or connection socket.

04:07.080 --> 04:09.300
The next step is the bind system call.

04:09.570 --> 04:16.590
In the next step the server needs to do bind followed by listen and then the server has to call the

04:16.590 --> 04:21.600
accept in order to wait for the connection from the new client.

04:22.170 --> 04:22.890
Right.

04:22.890 --> 04:30.100
And once the client connection request arrives using connect system call, you can see that the server

04:30.100 --> 04:32.830
process is unblocked from the accept system call.

04:32.830 --> 04:39.700
And then after that a server and the client process are actually engaged in the communication that is

04:39.730 --> 04:41.040
exchanging the data.

04:41.050 --> 04:48.280
So we will go through the code walk of implementing a server process and we will see that how each of

04:48.280 --> 04:53.050
these steps are implemented using Unix domain sockets.

04:54.310 --> 04:55.870
So let's start.
