So guys, let us see the demonstration of Dhcp server with multiplexing.
So the Dhcp server with multiplexing capability has been implemented in the file TCP server dot c.
So we will compile this file.
So the compilation process will create an executable called X underscore server.
You just have to run this binary.
So our TCP server with multiplexing has started and it has created the master socket file descriptor
and is now blocked on the select system call.
That is, it is now waiting for the connection initiation request from some client.
And now in the second window, you can see that we have a TCP client.
We have already discussed the implementation of TCP client and we need not do any changes in the TCP
client program.
It will continue to be exactly same as what we discussed.
So I can simply run the binary of TCP client that is the executable of TCP client program.
And you can see that the moment I start the TCP client program, the TCP client sends the connection
initiation request to the TCP server.
The server has accepted the connection request from the client and is again blocked on the select system
call.
And now it is either waiting for the data request from the connected client that is this client or it
can also receives the connection initiation request from some new client.
So let us say that the connected client sends some data to our TCP server.
Let us say it sends 10 or 20.
So you can see that your TCP client receives the response back from the server, right?
And your client is still connected with the TCP server and it can still carry out more data exchange
with the server.
Now let us say at this point of time a new client comes and it sends connection initiation request to
the server.
So let me start a new client program in the another window.
So I'm starting a new client program in another window, and you can see the moment I execute this,
the new TCP client sends the connection initiation request to the server.
So at this point of time, two clients are connected to our TCP server.
Right.
And now let's see if our TCP server can process the data request from the second client or not.
So let's say the second client sends the value 20 and 30 to the TCP server.
Oh, you can see that our TCP server has processed the data and sends the result back to the second
client.
Now let's see that whether our first client can still communicate with our TCP server or not.
So let's say our client C1 that is the first client sends the data to the TCP server.
Let's say it sends the value of A as nine and B as two, and it still receives the result.
Right.
And let's see if our second client can still communicate with the TCP server.
So let us send the value of A and B as 90 and 30 and it is receiving the result.
So you can see that both the clients are able to communicate with the TCP server and our TCP server
is able to process the data request from the two connected clients and entertain our process those requests
at the same time.
Right.
And while our TCP server is entertaining the connected clients, a new client can always come and join
the communication.
Right.
So this is what TCP server with multiplexing is supposed to do and we see that our TCP server is doing
its job fairly well.
Right.
So this is how a server should be designed, that it should be able to process the data request from
multiple connected clients as well as it should be in a position to process the connection initiation
request from the new client.
So this was Dhcp server with multiplexing capabilities implementation details for you.
So this is how TCP server with multiplexing are implemented.
And also, one more thing that I would like to point out that we are learning the entire TCP or socket
programming in C, and you can see that when you learn the stuff in C programming language, then you
really know what exactly you are doing.
You really do things at the lowest level of implementation.
Had you use Java or Python in order to implement these Dhcp servers or in order to do the socket programming,
you would have met the same result, but probably you will not be having the in-depth knowledge and
you will not be knowing that what exactly goes behind the scenes when you implement such a complicated
server logic.
So this is the benefit of learning stuff in C programming language because C language is neither a very
high level language nor it is a very low level language.
And yet it is a very powerful language and often termed as the mother of all the languages.