WEBVTT

00:04.950 --> 00:09.450
So guys, next we will going to understand the Linux except system call.

00:09.720 --> 00:14.370
So except system call plays a very vital role in socket programming.

00:14.820 --> 00:21.870
It is the accept system call which establishes the duplex or bidirectional communication between the

00:21.870 --> 00:26.610
client and the server processes which wants to communicate.

00:27.960 --> 00:33.300
So you can see in this diagram we have a server and we have already discussed that when a server boots

00:33.300 --> 00:35.410
up, that is when the server starts.

00:35.430 --> 00:42.000
The first thing the server process needs to do is to create a master socket file descriptor because

00:42.000 --> 00:47.250
it is the master socket file descriptor using which the server will accept the connection.

00:47.870 --> 00:54.440
Because the purpose of master socket file descriptor is only to establish the connection with the new

00:54.440 --> 00:55.250
clients.

00:56.720 --> 00:57.440
Right.

00:57.440 --> 01:04.070
So we assume that the server has booted up and it has created the master socket file descriptor already.

01:04.640 --> 01:12.590
Now when the server receives a new connection initiation request message from the new client, this

01:12.590 --> 01:19.550
connection initiation request message goes on a master socket maintained by the server that is master

01:19.550 --> 01:20.810
socket file descriptor.

01:20.990 --> 01:27.440
And whenever any message arrives on any socket, in this case the master socket file descriptor, that

01:27.440 --> 01:30.680
particular master socket file descriptor is activated.

01:31.610 --> 01:38.180
So you can see that the client C one sends the connection initiation request to the server.

01:38.300 --> 01:44.060
This connection initiation request always arrives at the master socket file descriptor of the server.

01:44.360 --> 01:47.840
This is done by the operating system itself.

01:47.840 --> 01:54.860
The underlying operating system always redirects the connection initiation request messages to the master

01:54.860 --> 01:56.930
socket file descriptor of the server.

01:58.560 --> 01:59.220
Right.

01:59.220 --> 02:05.160
So in the next step, when the server receives connection, initiation requests from the new client

02:05.160 --> 02:10.800
server invokes the accept system call to establish the bi directional communication.

02:10.980 --> 02:15.750
So in the next step, the server has invoked the accept system call.

02:17.530 --> 02:22.570
So remember, whenever the server receives the connection initiation request on a master socket file

02:22.570 --> 02:28.060
descriptor, the next step is always to invoke the accept system call.

02:28.270 --> 02:36.880
And as a result of invoking the accept system call the server creates a client handle or communication

02:36.880 --> 02:37.880
file descriptor.

02:37.900 --> 02:44.200
So the return value of accept system call is a client handle which we also call as communication file

02:44.200 --> 02:45.040
descriptor.

02:45.520 --> 02:46.160
Right.

02:46.180 --> 02:49.060
So remember, it is always an integer value.

02:49.060 --> 02:52.750
It could be six, it could be seven, eight or anything else.

02:52.780 --> 02:59.230
So when we will be discussing the code, we will see that file descriptors, whether it is communication

02:59.230 --> 03:04.060
file descriptor or master socket file descriptors are always integer values.

03:06.350 --> 03:12.650
Now, once the communication file descriptor for client C1 is created, the server will use this handle

03:12.680 --> 03:15.740
to carry out actual data exchange with the client.

03:15.770 --> 03:16.400
C1.

03:18.270 --> 03:18.800
Right.

03:18.810 --> 03:25.800
The server will use this handle to send the data as well as to receive the data from the client.

03:25.840 --> 03:26.520
C1.

03:27.720 --> 03:34.470
So you can see here that the client handles are used for actual communication with the client.

03:36.460 --> 03:36.990
Right.

03:37.570 --> 03:42.880
Also accept system call is used only for connection oriented communication.

03:42.880 --> 03:46.330
It is not used for connectionless communication.

03:46.330 --> 03:50.170
So there are two types of communication between the client and the server.

03:50.560 --> 03:56.560
The first type of communication is called connection oriented communication, and the second type of

03:56.560 --> 04:00.040
communication is called Connectionless communication.

04:01.550 --> 04:08.090
We shall discuss in detail that what are the properties of connection oriented communication and connectionless

04:08.090 --> 04:10.820
communication in the next slide.

04:11.600 --> 04:16.970
But remember, except system call is used only when the type of communication between the client and

04:16.970 --> 04:20.540
the server is connection oriented communication.

04:22.170 --> 04:22.800
Right.

04:22.800 --> 04:29.160
So likewise, going forward, suppose a client C two, which is now a new client, also sends the connection

04:29.160 --> 04:31.350
initiation request to the server.

04:31.380 --> 04:35.700
The master socket will be activated and the accept system call will be invoked.

04:35.700 --> 04:41.790
And as a result, a new client handle will be created which will be used by the server for carrying

04:41.790 --> 04:44.520
out data exchange with the client.

04:44.550 --> 04:45.210
C two.

04:47.620 --> 04:53.020
So you can see here that except system call is used to create client handles.
