WEBVTT

00:00.210 --> 00:09.930
I'd let's begin with the chat up now so we can create a chat up by saying you package and let me create

00:10.230 --> 00:12.050
chat up here.

00:12.390 --> 00:19.880
So in this particular chat up let me say new place and find Of course it's going to be a client and

00:19.880 --> 00:22.330
there's going to be a civil.

00:22.410 --> 00:28.890
Things are pretty much the same but of course when we do it more number of times you will be more familiar

00:28.890 --> 00:29.550
with it.

00:29.580 --> 00:38.400
What we are trying to do so we can close up all the other applications for multi-threading chat chat

00:39.240 --> 00:40.560
chat app.

00:40.620 --> 00:42.510
This is the kind of server chat.

00:42.560 --> 00:42.880
OK.

00:42.930 --> 00:44.050
Networking Sure.

00:44.220 --> 00:47.340
So we calls all of them just declined and server for chat.

00:47.370 --> 00:51.610
This is started let's say in the client that we buy.

00:51.930 --> 00:57.350
Let me say compote let me call it simple.

00:57.990 --> 01:02.460
So we have of course I need to import socket.

01:02.790 --> 01:08.410
Things are pretty much the same but we got to do that again so that you want to set a very well socket

01:08.410 --> 01:12.090
that socket create a client socket plate.

01:12.150 --> 01:20.430
So we call the CSR now plain socket and server socket is going to be in both socket.

01:20.940 --> 01:29.080
So as to be in to suck it I will say sucking cock sucking right.

01:29.220 --> 01:29.870
Sure.

01:29.990 --> 01:30.830
Let me call this this.

01:30.830 --> 01:32.460
SS That's a service.

01:32.830 --> 01:34.890
Okay now.

01:35.330 --> 01:38.590
SS Daut of course you need to find it.

01:38.720 --> 01:48.510
And after finding them you need to say to start listen listen for clients but now.

01:49.070 --> 01:57.860
Now comes the question I cannot I cannot connect to one plane because my server now will connect to

01:57.860 --> 01:58.580
multiple clients.

01:58.580 --> 02:03.350
I want to make a chat with many clients talking to each other see one client here.

02:03.350 --> 02:07.490
One client here one client here lets see each of them want to talk to each other.

02:07.580 --> 02:08.530
Why so.

02:08.630 --> 02:10.780
So there's a sober in-between.

02:11.060 --> 02:15.490
And each of them are going to talk to each other just like the picture that we just saw.

02:15.710 --> 02:22.620
So you're going to have client one client to client required for one to have four clients each of them

02:22.620 --> 02:27.650
want to communicate with each other or chat with one another writer or whatever the sclayn say is let's

02:27.650 --> 02:34.580
say this is ABC whatever he sends should be displayed on the screens of all the three by saying ABC

02:34.580 --> 02:42.350
said this and they say this client's name the x y z and he sends a message displayed on these lines

02:42.860 --> 02:48.710
as x y z said this so you should have multiple clients talking to each other.

02:48.710 --> 02:49.390
Why are the soaps.

02:49.430 --> 02:51.890
So you're basically broadcasting messages.

02:52.010 --> 02:53.760
So that's what you're going to do.

02:53.900 --> 02:54.650
So.

02:55.010 --> 03:02.090
So you cannot just say connect to you know accept a particular client out here you can do that rather

03:02.770 --> 03:03.130
rather.

03:03.140 --> 03:08.950
Now what we're going to do is because we need to keep accepting clients once again again and again there

03:08.950 --> 03:11.510
can be multiple clients I need to say.

03:11.510 --> 03:13.440
SS Right.

03:13.910 --> 03:19.850
I need to keep I need to keep getting these multiple questions out there so I'm going to say esus dot

03:20.720 --> 03:22.890
dot except OK.

03:23.030 --> 03:27.520
So here I'm going to accept multiple clients let me call this kind.

03:27.520 --> 03:29.460
Come a ADR.

03:29.750 --> 03:30.290
Right.

03:30.290 --> 03:36.570
So I'm going to say you know I'm just going to print.

03:37.100 --> 03:38.140
Got a connection

03:41.240 --> 03:49.380
from client and address Comox come an 18 year break.

03:49.490 --> 03:58.900
So I printed that up and then I say out here are we here you say print after they print this up like

03:58.900 --> 04:01.930
we call it is after printing them.

04:02.300 --> 04:08.500
I'm going to say look at the connection I need to store this particular content.

04:08.630 --> 04:10.830
At least this address along with a name.

04:10.880 --> 04:16.610
So what I'll do is at the client side after they connect OK so I'm going to connect so I'm going to

04:16.610 --> 04:20.840
say she has done so I'm going to connect to.

04:21.020 --> 04:30.000
Of course I'm going to connect to localhost come on the address let me say post-combat 2000.

04:30.240 --> 04:36.550
The server has not been bound to bind it to 2000

04:39.200 --> 04:41.020
right after you buy it.

04:41.090 --> 04:48.950
And you're going to get some data which you need to after you connect to the particular server you need

04:48.950 --> 04:57.140
to do one thing that is send send your you don't take input from the user whenever the client comes

04:57.150 --> 05:02.560
just taking input from the user and enter your name.

05:02.600 --> 05:08.300
So when the client enters you know you ask him his name.

05:08.390 --> 05:18.020
Store that name and when you get the name or you can do as you can the minute you connect send it to

05:18.050 --> 05:26.800
the server send to the server saying saying what the senders name so name thought and code centered

05:26.840 --> 05:32.660
as bytes is a string so encoded is bytes and just send it to the server which means the server the minute

05:32.660 --> 05:34.520
it gets a connection from the client.

05:34.550 --> 05:37.350
The next thing is it should wait for it.

05:37.430 --> 05:38.520
It should get some data.

05:38.530 --> 05:44.420
It should you should receive some data around thousand bytes receive it.

05:44.420 --> 05:50.100
Store it and store it in name of the client that has just come.

05:50.780 --> 05:51.570
OK.

05:51.740 --> 05:56.170
Now when this happens what you can do is he can start a trade.

05:56.180 --> 05:57.760
Let me call this trade.

05:58.100 --> 05:59.510
He's equal to trade.

05:59.510 --> 06:05.150
Let me call this a trade and let's say I'm going to pass these parameters.

06:05.180 --> 06:11.160
OK so I'm going to say Target target he called to let me call this client underscore task.

06:11.160 --> 06:16.420
I'm going to call call functions or cleanse task which means I need to have a function out here.

06:16.430 --> 06:22.070
Then we Cardus desk climb and score that task.

06:22.250 --> 06:29.120
And of course trading Also I need to import from trading impose trade

06:31.670 --> 06:39.200
rights so I create this task and after I had that particular target.

06:39.200 --> 06:44.800
So I need to go along with clients that let me pass a few arguments.

06:44.810 --> 06:56.810
Let me pause the client name right the client address right.

06:57.080 --> 07:01.460
And and the connection of course you require the connection.

07:01.460 --> 07:04.590
So let me call it S. Klein.

07:04.770 --> 07:05.390
KLEIN

07:08.000 --> 07:14.780
So accepted these three things which means I need to send these as arguments are GSC equal to a couple

07:14.900 --> 07:15.850
of these three.

07:15.980 --> 07:17.330
So do I have each of them.

07:17.330 --> 07:24.870
Yes I have name I have as one of the arguments I have kyne and I have ADR which can be passed.

07:24.930 --> 07:28.460
These three can be passed as arguments to those three.

07:28.670 --> 07:29.180
Right.

07:29.390 --> 07:35.260
So I can create this thread and all and it was that stopped.

07:35.420 --> 07:36.160
Correct.

07:36.230 --> 07:42.470
That will start the particular but of course all instead of name it should be because the name that

07:42.470 --> 07:44.400
you receive is going to be in bytes.

07:44.570 --> 07:45.290
I should do.

07:45.290 --> 07:50.710
Name dot de-code and then send it out.

07:51.020 --> 07:52.820
So decoded and then send it up.

07:52.940 --> 07:54.820
So that's cool.

07:55.540 --> 08:01.210
And then the one task you can do whatever the class or whatever it's doing you know whatever it wants

08:01.210 --> 08:01.750
to do.

08:01.750 --> 08:06.760
OK so if the client has each of the Cline's are going to be on different thread altogether.

08:06.760 --> 08:09.030
So the client tasked each of them is going to be different.

08:09.130 --> 08:09.540
Right.

08:09.670 --> 08:14.800
So because each of them one when new threats are created and client task is called so each client is

08:14.800 --> 08:16.890
going to have a separate.

08:16.960 --> 08:19.120
Each client is going to have a separate client task.

08:19.330 --> 08:25.480
And that let's say we're going to use these arguments we're going to what we're going to do is of course

08:25.570 --> 08:29.980
we have to do just the client asks only this much.

08:30.130 --> 08:33.910
Whatever they get from one client send it to all the clients.

08:34.030 --> 08:36.550
So let's say I have to receive.

08:36.550 --> 08:42.550
So basically I need to have a while to cheer and then keep receiving from whatever's the connection.

08:42.550 --> 08:50.640
So let me say Klein kind dot receive receive Let's say I received thousand bytes of data.

08:51.190 --> 08:52.860
So.

08:53.050 --> 08:56.300
So let me say data which I guessed.

08:56.440 --> 09:03.070
OK that data is going to be I need to send it to all the other clients so basically I need to get this

09:03.070 --> 09:05.880
data and I need to send it to all the other clients.

09:05.920 --> 09:08.550
Oh but I don't know the other clients right.

09:08.550 --> 09:13.750
You know I didn't know when I come to a particular client us do I have the connections of all the other

09:13.750 --> 09:14.650
clients.

09:14.680 --> 09:20.110
No I don't have hands I need to store these particular clients the minute I get a client I need to store

09:20.110 --> 09:21.200
them in a dictionary.

09:22.320 --> 09:23.270
Right.

09:23.360 --> 09:26.120
Create a dictionary let me call them clients.

09:26.120 --> 09:29.080
I'll create a simple dictionary of clients.

09:29.330 --> 09:35.870
We're just going to be empty at the start but the minute I get a particular client I should.

09:36.240 --> 09:38.180
What I can do along with the name.

09:38.350 --> 09:42.670
Once I get it I should add that in the dictionary.

09:42.770 --> 09:45.490
So I take clients off.

09:45.740 --> 09:49.370
I give out one of the name that I've got.

09:49.380 --> 09:53.300
OK so name not just names should be named logicals sorry.

09:53.450 --> 10:00.740
So the name that de-code Klein's name but de-code I should say that should be called to I should be

10:00.790 --> 10:08.290
make it equal to the two let's say and send in the values with the connection right.

10:08.300 --> 10:08.990
So that.
