UDP socket.
Hello, everyone.
Today, we're going to talk about the client and I'm going to show you a very easy application with
which you can chat with yourself or with your friends.
So let's not lose any more time.
And I will keep this terminal windows.
But what I will do is go to the HRO and create one new file.
So the file will be Euterpe client, obviously.
So let's write UDP underscore client.
OK, and here we can import some stuff.
So let's write user slash bin slash ian fee Python three and then let's import sockets and then let's
again out of the IP address, the UDP port and the buffer.
So I write your DP IP will be equal to a hundred and twenty seven to zero zero dot one.
OK, and then I will create your DP or it will be one, two, three, four or five.
OK, and then the buffer will be equal to four zero nine six.
OK, now let's create the address so all of us here will be equal to Euterpe actually.
Yes.
Here is your DP in here.
So Sudip.
Just to be certain.
So let's try to UDP, IP Como, UDP or not.
OK, so this is the address in the list and the list socket client who will called to socket.
The socket, and then I write.
Socket, not a.
In a minute and then circuit not so good, did your.
Not sit here and listen right now, while true and hear our right message equals.
Input.
And here we are going to ask the user to write the message, and this will be our first chat functionality,
it's all right, enter.
Your message.
OK.
And then that's right, if.
Message equals exit.
Then I would like to exit the application, so I will do break.
OK, then let's write socket that actually underscore client dot.
Sent to OK, so here we usually sent to function and dysfunction.
We need to pass a message.
Dot and call to work and called the message, and then we have the address, OK?
And then let's write a response.
Colma others will give equal to sockets, underscore client and then let's write the receive from Koman
and in the briskets they write the buffer.
OK so the number of bytes and then let's print.
OK server response and then is.
And after the percent, it will be response.
The third and final circuit, Colossians Dot.
Close.
OK.
Also here we are getting nearer and right now, of course, and of course, America's enemies that we
are checking for this, but not the U.S., not equal to it.
But anyways.
Right.
The double crossing here, just to be certain.
So once you're ready, we just file guys.
Let's create a new one in.
The next file is going to begin a Python file into the code UDP underscore server and say, is this
the server?
This file will be a little bit longer.
So let's write the hash tag and mark and then user been.
EMV and then Python three, and now we can play freely, import the sockets and also the NSW Library
and the right UDP underscore.
IP will be equal to a hundred and twenty seven to zero zero, not one.
OK, then let's create UDP fourth in here.
This will be go to the numbers from one to six.
And after that, the last thing I want is the the buffer, which will be equal to forty nine to six.
And then let's create the host server.
So I will do socket underscore server who will be close to socket dot socket and then the brick this
right socket underscore server underscore and then receive from.
Actually we're not going for that at this time because I first want to add to the Affinia.
So if that socket here again not A.F. in it and if s again socket but SOC.
Stream, OK, and then let's up socket server, not blind and then that's right, UDP underscore I.T.
and common socket and dot soc høst.
Are you OK?
So Høst or actually let me write in a better way.
So here I'm actually going to use the underscore port.
It makes more sense to make the whole server from the IP and the port and so we're already here today.
So let's right now while.
Through, OK, the prince waiting for the land.
OK, then this right there, the common address next to not by paladares, but only address.
So there are others will be equal to a circuit server.
Not receive from and in the firm, and then there will be quote to daro that strip.
OK.
And finally last night, friends they received from.
From Madras and this right that so it will be just the address.
OK, and let's just please come before that so it understands it.
You can see that we don't have any more errors.
And finally, I'm going to print here message and then right there.
OK.
So, guys, we're almost there.
First of all, here we need, I'm pretty sure, an equal sign between those two.
And let's now make some exceptions.
So if our code doesn't work, we're aware about the errors.
So let's do respons equals high, then let's try percent s and percent.
This is wise.
But what for?
OK, and then let's do.
Except for the exception and then exception, us e and let me actually remove the same column here,
so let's the response will be equal to or less than percent since DOT.
And here I will use the option, exclude info and then it's right to zero.
Then let's print here.
Correction.
I'm going to print on the same irritation level.
So print.
And then response and then response, and that's it.
And finally, let's put another statement in this statement to talk about the response.
Let's write response.
And for just the person that is going to be liable for the response is going to be the one that is outside
this exception here.
So let us to hear a response.
That's it.
And after that, actually it on the same level, let's to circuit underscore server dot.
Send.
To and to illustrate the response, not in cold.
And then.
Address, OK?
And finally, after we agreed with that list, simply right socket underscore server dot laws and let's
just try the parentheses.
So once the files are ready, guys, let's go back to our terminals and let's write quiz in the first
one in here.
I'm going to lunch with the UDP server, so let's write Python.
So let's write here Python.
And I did an error with the name, but it actually does matter.
So let's do Python USPI even though to the server, let's run it.
And here we can see that we have some error.
So let's see.
Line fifty seven or it's actually 14, if I'm careful.
And here again, you can see that we have on there actually and let's see what there is.
So I can see that here we need to have S. instead of C.
S or actually here is actually a response instead of resource.
So let's do.
Response, let's have it, and so that is really here with the cold guy, so this is our client here.
Let's try it again.
So item USPI server your way and we're getting Canaro, which is not connected there.
Obviously, we're getting that through because we didn't connect the server first.
So let's actually go to the terminal and do Biton DCP server way.
And if I run it, you can see that nothing happens.
But let's run out the client and we're getting here already in use error.
So let's see what the issue is here.
So you can see, guys, that the server is waiting for a client and actually here to run the Klan for
here.
But I didn't do it.
So Labor closed this terminal and terminate the process.
And I will pull up on Arawa and let's go to the desired folder.
So let's just see.
So once I go for the right for in the terminal and then right away now it's time to run the actual client
since the server is already waiting.
So let's write Python and then you, DP client, OK, and now after a run, the client, you can see
that I'm getting here.
Enter your message, which basically comes from this statement here.
Enter your message.
Acadia's our input and if I enter the message high, then the server received a message from this IP
address on Gispert that is saying hi and so on.
If I sent another message, for example, what?
So you can see that again, I receive a message here.
So they are communicating through the port one, two, four or five, an IP address, 127 DOT 0.01 extricates,
if you would like to experiment more with those who can send a few more messages.
But I think for the purpose of this video, that's completely enough.
And actually this was the last video from this section.
So I want to thank you that you followed the discourse and discussion with me.
Think very much for watching and I'm going to see you in our next adventure.