WEBVTT

00:04.980 --> 00:09.210
So guys, now let us do one small assignments on thread listeners.

00:09.480 --> 00:15.000
So in this example or in this assignment, we will going to create a small application called listener

00:15.000 --> 00:15.920
main dot exe.

00:16.170 --> 00:16.860
Right.

00:17.040 --> 00:21.120
This application would going to listen on multiple events at the same time.

00:21.660 --> 00:27.690
So what we will going to do is that that our listener main dot exe application would going to launch

00:27.690 --> 00:28.950
two listener threads.

00:29.250 --> 00:32.790
Both the listener threads listens on an IP address.

00:32.790 --> 00:40.010
127 .0.0.1 and on UDP port number 3000 and 3001 respectively.

00:40.020 --> 00:40.710
Right.

00:40.710 --> 00:46.080
So we will going to launch two packet listener threads and both the packet listener threads would going

00:46.080 --> 00:49.200
to listen on an IP address and UDP port number.

00:49.470 --> 00:54.150
Now our application will have a function called packet receive function.

00:54.150 --> 00:54.840
Right?

00:54.840 --> 01:01.260
And the purpose of this packet receive function is to process the packet which our application is receiving

01:01.260 --> 01:02.700
from the outside world.

01:02.910 --> 01:08.830
So what our packet listener thread is supposed to do is that they will going to listen on an IP address

01:08.830 --> 01:14.740
and port number and once these packet listener thread receives the packet from the outside world, it

01:14.740 --> 01:22.450
is the responsibility of these packets to inject or pump those packets into the application main code

01:22.450 --> 01:26.500
so that our application can process those packets right.

01:26.680 --> 01:32.650
Now in this function that is packet receive function, you don't have to write some sophisticated code

01:32.650 --> 01:35.440
to parse or process the packet.

01:35.470 --> 01:39.640
It is enough that you simply print some message that you have received some packet.

01:39.640 --> 01:42.430
For example, you can print the packet size, right?

01:43.580 --> 01:49.160
Packet receive function is simply the representation that our main application is receiving the packets

01:49.160 --> 01:52.730
from the outside world via packet listener threads.

01:52.730 --> 01:53.480
Right.

01:53.780 --> 01:58.370
Then also our application must be in a position to interact with the user.

01:58.370 --> 02:04.040
So we will going to launch a third thread called user interaction thread and its responsibility will

02:04.040 --> 02:08.570
be only to receive inputs from the user and act on those inputs.

02:08.570 --> 02:09.230
Right?

02:09.410 --> 02:14.870
So in order to design this application, you need some socket programming because you would going to

02:14.870 --> 02:19.640
launch packet listener threads which will going to listen on the sockets, right?

02:19.640 --> 02:26.270
So for that I have provided the library network utils, storage and network utils dot c in this files

02:26.270 --> 02:31.970
you have two APIs, UDP server create and start and UDP send message.

02:31.970 --> 02:32.630
Right?

02:32.870 --> 02:36.800
You need to use these APIs in order to accomplish this assignment.

02:37.520 --> 02:43.130
I have also provided a separate executable called UDP sender dot x.

02:43.130 --> 02:43.730
Right.

02:43.730 --> 02:51.650
Using this executable you can actually generate UDP packets which are targeted to port number 3000 or

02:51.650 --> 02:52.280
3001.

02:52.280 --> 02:52.880
Right?

02:52.880 --> 03:00.020
So you can use UDP standard dot x, which is already cooked up application in order to send packets

03:00.020 --> 03:05.930
to your listener main dot x application and test whether your application is working as expected or

03:05.930 --> 03:06.560
not.

03:06.560 --> 03:07.310
Right?

03:07.790 --> 03:11.840
So let us code up the listener main dot x and see things in action.

03:11.840 --> 03:14.120
And of course this section needs that.

03:14.120 --> 03:17.150
You have some basic background in socket programming.

03:17.270 --> 03:24.080
So now in the next lecture video, let us see how to write listener underscore main dot x application

03:24.080 --> 03:29.600
and after that there will be some couple of assignments in which you will going to add up some additional

03:29.600 --> 03:33.590
logistics to this multiple events listening application.

03:33.590 --> 03:34.220
Right.
