WEBVTT

00:00.360 --> 00:02.100
So it's picking up the chant.

00:02.100 --> 00:02.940
What application.

00:02.940 --> 00:10.030
What we can do is we can start up with the new package for now and let's call it this chat.

00:11.160 --> 00:19.640
OK so I call this chat board and then let me begin a new fight and file in that let me call it as client.

00:19.770 --> 00:23.100
And of course we're going to have one more.

00:23.120 --> 00:27.730
Let me call this new python file and a server.

00:27.850 --> 00:35.030
It's now because there are two coins insurers open you know exactly you have a chat server a checkout

00:35.070 --> 00:39.800
line and a networking server networking client which is another package altogether.

00:40.080 --> 00:42.860
So we're going to be able to chat but all of them.

00:43.410 --> 00:43.930
OK.

00:44.100 --> 00:51.150
So steps are the starting few steps of the same where the import socket create a socket by saying socket

00:51.150 --> 00:52.740
that socket.

00:52.740 --> 01:01.770
So you need to create a Quine's arcade by saying Quine underskirt sacque rate equal to.

01:01.800 --> 01:06.150
So there's your client socket which you need to use for connecting to the server.

01:06.150 --> 01:10.430
So let me connect to the server client socket connect.

01:10.760 --> 01:19.210
OK so you're connecting to the server let me call let me call the server to be at a particular the locals

01:19.310 --> 01:20.070
address right.

01:20.100 --> 01:29.340
Local host it's at the same address but the port Demaris 42000 right Klein socket that connect.

01:29.370 --> 01:29.610
OK.

01:29.640 --> 01:33.540
So once you connect I need to send and receive right.

01:33.570 --> 01:35.580
Two things that needs to be done up to now.

01:35.610 --> 01:38.690
So do this much even on the server side where.

01:38.880 --> 01:41.640
Let me say I'm poat socket.

01:42.150 --> 01:50.420
I create a socket object by saying socket socket.

01:51.290 --> 01:54.910
And let me call this a server socket.

01:55.150 --> 01:56.000
Great.

01:56.450 --> 02:01.590
And then of course the server socket will do well.

02:01.910 --> 02:15.050
Let's say it will what it has to do is it has to let's say bind itself right bind itself to a cross.

02:15.080 --> 02:16.850
It has to be empty.

02:16.850 --> 02:20.490
Come on come on a boat with just two towers.

02:20.540 --> 02:20.860
Right.

02:20.870 --> 02:22.630
So which I can give it later.

02:22.700 --> 02:26.850
I can get some outside number.

02:28.840 --> 02:34.940
So come up post ups pope number or two thousand.

02:38.970 --> 02:41.820
Write so I bound it to a particular part.

02:41.880 --> 02:47.760
Now of course this also when you connect you need to have a couple that won't work if it's not a topple

02:47.760 --> 02:52.360
because you can have only one parent meter in this particular connect mentors.

02:52.550 --> 02:52.920
Right.

02:52.920 --> 02:59.700
So you connect to this particular you bind them to a particular port number and after you bind so socket

02:59.700 --> 03:05.110
or bind what you can do is you know to bind them.

03:05.190 --> 03:07.720
You need to keep listening to the server socket.

03:07.740 --> 03:11.270
Listen that's where you get the clients.

03:11.520 --> 03:13.000
Of course you need to accept it.

03:13.200 --> 03:15.820
Let's say Services had died.

03:16.170 --> 03:20.910
Except now this excerpt will return to you to things that is kind.

03:20.910 --> 03:22.230
Come on.

03:22.280 --> 03:27.250
Here are two things a return to you the connection and the address.

03:27.330 --> 03:31.570
Two things which you need to store it in case the con is another.

03:31.590 --> 03:37.840
As you know it is just another object which you can use for for connecting.

03:37.860 --> 03:38.410
Right.

03:38.580 --> 03:39.210
OK.

03:39.510 --> 03:44.380
So with this done all you can do is consummated yours finds the server socket.

03:44.400 --> 03:48.630
Except now all that can be done is let's say

03:51.810 --> 03:55.780
up to you get that kind come a DVR.

03:55.920 --> 04:02.620
I need to say talk send data as well as I received it.

04:02.620 --> 04:07.310
Both must happen simultaneously both from the client side and from the server side.

04:07.320 --> 04:09.590
Both must happen at the same time.

04:09.600 --> 04:10.080
Right.

04:10.080 --> 04:13.130
That's what we need to do both client side and the service.

04:13.170 --> 04:20.460
So what we need to do is we do have to trace which means basically for now a main thread and a part

04:20.460 --> 04:27.320
time thread right where def can be you know this particular there can be one matter.

04:27.420 --> 04:32.160
It is for receiving data receiving data.

04:32.370 --> 04:33.350
OK.

04:33.510 --> 04:38.630
And there can be another method for sending.

04:38.980 --> 04:40.070
Right.

04:40.200 --> 04:44.040
So let's say I use one method for receiving data.

04:44.100 --> 04:46.340
Another method for sending.

04:46.560 --> 04:47.090
OK.

04:47.160 --> 04:55.860
Now in receiving what I wan in receiving data is I need to do kind Dorte RACV I need to keep receiving

04:56.520 --> 05:04.020
at least thousand bytes from the server side and whatever I get I will have it in data and after I get

05:04.020 --> 05:12.930
data I can just for now aim to do data to decode because it's in bytes I need to decode that.

05:13.110 --> 05:22.340
And after I decode it I need to just print it by saying OK rather de-code I understand that the data

05:22.380 --> 05:23.910
de-code But what is this data.

05:23.910 --> 05:25.640
This data is coming from the server.

05:25.650 --> 05:36.400
So a typical server will have something like this server in space Kummer data the teacher great.

05:36.590 --> 05:42.200
So you don't the space will be all provided by the CEP mattered so that space will all get there.

05:42.380 --> 05:47.700
So the server has and this particular data which I received and they print on my screen so this is preceded

05:47.800 --> 05:56.450
apart but sending the pod is where I need to send data by saying my saying you know I need to take something

05:56.450 --> 05:59.360
from the user let me put something in the user and then send it out.

05:59.540 --> 06:03.340
Let's input enter data to be our.

06:03.340 --> 06:06.490
Don't say anything just let it be as it is.

06:06.570 --> 06:07.200
OK.

06:07.430 --> 06:11.590
Now whatever you input OK whatever your input.

06:11.630 --> 06:14.760
I of course it's going to be empty string for now.

06:14.930 --> 06:21.530
I need to take that into I need to take that into let's say user input right.

06:21.530 --> 06:23.060
That's user input.

06:23.060 --> 06:25.440
Now what can you do with this particular data.

06:25.490 --> 06:28.790
I need to send it to the server after encoding.

06:28.810 --> 06:37.730
So user input data in code that encode I need to encode this and then send it to the server by saying

06:37.730 --> 06:41.530
come on Nakhon sorry uncandid receive.

06:41.570 --> 06:43.430
I made a mistake out here too.

06:43.490 --> 06:45.990
It's not Kollin but coiners core socket.

06:46.040 --> 06:48.690
That's Conne will come on the server side.

06:48.800 --> 06:55.810
This will be the client the socket Daut send our.

06:55.860 --> 07:02.740
So I send data on to the client socket site and so encode it and send it there.

07:02.740 --> 07:07.370
So these are two functions so I need to create one thread.

07:07.780 --> 07:13.900
So the main so I can have one thread for sending and one thread for receiving.

07:13.900 --> 07:14.520
Right.

07:14.740 --> 07:16.720
So let me see I create a thread.

07:16.720 --> 07:18.690
Let me say T is equal to thread.

07:18.700 --> 07:21.750
I create a thread so it tells me there is.

07:21.760 --> 07:25.540
It shows me an on the line saying that no unresolved reference thread.

07:25.540 --> 07:28.660
There is no such thread which means I need to import

07:31.500 --> 07:37.910
from trailing import thread.

07:38.180 --> 07:44.690
Right so I need to import trade out there and I need to say after creating the thread I need to say

07:45.300 --> 07:46.530
what is my target.

07:46.530 --> 07:50.340
Let me put my received data as my target.

07:50.340 --> 07:52.620
Receiving the error can keep happening.

07:53.020 --> 07:57.220
You know as a thread it can keep happening again and again.
