1 00:00:04,870 --> 00:00:06,380 UDP socket. 2 00:00:06,820 --> 00:00:07,660 Hello, everyone. 3 00:00:07,990 --> 00:00:13,870 Today, we're going to talk about the client and I'm going to show you a very easy application with 4 00:00:13,870 --> 00:00:16,970 which you can chat with yourself or with your friends. 5 00:00:16,990 --> 00:00:19,030 So let's not lose any more time. 6 00:00:19,030 --> 00:00:21,230 And I will keep this terminal windows. 7 00:00:21,710 --> 00:00:28,240 But what I will do is go to the HRO and create one new file. 8 00:00:28,510 --> 00:00:32,650 So the file will be Euterpe client, obviously. 9 00:00:32,800 --> 00:00:37,170 So let's write UDP underscore client. 10 00:00:37,540 --> 00:00:40,210 OK, and here we can import some stuff. 11 00:00:40,420 --> 00:00:54,640 So let's write user slash bin slash ian fee Python three and then let's import sockets and then let's 12 00:00:54,640 --> 00:00:58,770 again out of the IP address, the UDP port and the buffer. 13 00:00:59,110 --> 00:01:10,600 So I write your DP IP will be equal to a hundred and twenty seven to zero zero dot one. 14 00:01:11,080 --> 00:01:17,580 OK, and then I will create your DP or it will be one, two, three, four or five. 15 00:01:18,010 --> 00:01:24,340 OK, and then the buffer will be equal to four zero nine six. 16 00:01:24,640 --> 00:01:31,320 OK, now let's create the address so all of us here will be equal to Euterpe actually. 17 00:01:31,330 --> 00:01:31,870 Yes. 18 00:01:32,800 --> 00:01:35,920 Here is your DP in here. 19 00:01:35,920 --> 00:01:36,840 So Sudip. 20 00:01:38,510 --> 00:01:39,560 Just to be certain. 21 00:01:39,770 --> 00:01:47,300 So let's try to UDP, IP Como, UDP or not. 22 00:01:47,510 --> 00:01:55,760 OK, so this is the address in the list and the list socket client who will called to socket. 23 00:01:57,170 --> 00:02:00,560 The socket, and then I write. 24 00:02:01,910 --> 00:02:04,160 Socket, not a. 25 00:02:06,050 --> 00:02:13,220 In a minute and then circuit not so good, did your. 26 00:02:15,430 --> 00:02:24,250 Not sit here and listen right now, while true and hear our right message equals. 27 00:02:25,510 --> 00:02:26,240 Input. 28 00:02:26,260 --> 00:02:32,890 And here we are going to ask the user to write the message, and this will be our first chat functionality, 29 00:02:33,190 --> 00:02:34,630 it's all right, enter. 30 00:02:35,940 --> 00:02:37,980 Your message. 31 00:02:39,820 --> 00:02:40,440 OK. 32 00:02:42,280 --> 00:02:44,800 And then that's right, if. 33 00:02:45,980 --> 00:02:49,730 Message equals exit. 34 00:02:50,240 --> 00:02:54,350 Then I would like to exit the application, so I will do break. 35 00:02:54,620 --> 00:03:01,910 OK, then let's write socket that actually underscore client dot. 36 00:03:03,690 --> 00:03:08,280 Sent to OK, so here we usually sent to function and dysfunction. 37 00:03:08,310 --> 00:03:10,680 We need to pass a message. 38 00:03:12,200 --> 00:03:19,100 Dot and call to work and called the message, and then we have the address, OK? 39 00:03:19,220 --> 00:03:21,320 And then let's write a response. 40 00:03:21,620 --> 00:03:32,180 Colma others will give equal to sockets, underscore client and then let's write the receive from Koman 41 00:03:33,590 --> 00:03:36,630 and in the briskets they write the buffer. 42 00:03:36,800 --> 00:03:42,220 OK so the number of bytes and then let's print. 43 00:03:43,040 --> 00:03:47,810 OK server response and then is. 44 00:03:49,550 --> 00:03:53,150 And after the percent, it will be response. 45 00:03:54,960 --> 00:04:02,360 The third and final circuit, Colossians Dot. 46 00:04:03,470 --> 00:04:03,960 Close. 47 00:04:04,460 --> 00:04:05,000 OK. 48 00:04:05,070 --> 00:04:10,610 Also here we are getting nearer and right now, of course, and of course, America's enemies that we 49 00:04:10,610 --> 00:04:14,820 are checking for this, but not the U.S., not equal to it. 50 00:04:15,260 --> 00:04:16,150 But anyways. 51 00:04:16,160 --> 00:04:16,790 Right. 52 00:04:17,120 --> 00:04:19,410 The double crossing here, just to be certain. 53 00:04:19,760 --> 00:04:22,090 So once you're ready, we just file guys. 54 00:04:22,130 --> 00:04:23,930 Let's create a new one in. 55 00:04:23,930 --> 00:04:32,370 The next file is going to begin a Python file into the code UDP underscore server and say, is this 56 00:04:32,390 --> 00:04:33,020 the server? 57 00:04:33,290 --> 00:04:34,960 This file will be a little bit longer. 58 00:04:35,870 --> 00:04:43,970 So let's write the hash tag and mark and then user been. 59 00:04:45,340 --> 00:04:59,080 EMV and then Python three, and now we can play freely, import the sockets and also the NSW Library 60 00:04:59,710 --> 00:05:03,370 and the right UDP underscore. 61 00:05:04,570 --> 00:05:13,450 IP will be equal to a hundred and twenty seven to zero zero, not one. 62 00:05:13,750 --> 00:05:17,880 OK, then let's create UDP fourth in here. 63 00:05:17,880 --> 00:05:20,620 This will be go to the numbers from one to six. 64 00:05:20,890 --> 00:05:29,710 And after that, the last thing I want is the the buffer, which will be equal to forty nine to six. 65 00:05:30,250 --> 00:05:33,900 And then let's create the host server. 66 00:05:33,930 --> 00:05:46,060 So I will do socket underscore server who will be close to socket dot socket and then the brick this 67 00:05:46,060 --> 00:05:52,960 right socket underscore server underscore and then receive from. 68 00:05:53,200 --> 00:05:59,200 Actually we're not going for that at this time because I first want to add to the Affinia. 69 00:05:59,410 --> 00:06:12,130 So if that socket here again not A.F. in it and if s again socket but SOC. 70 00:06:13,160 --> 00:06:27,610 Stream, OK, and then let's up socket server, not blind and then that's right, UDP underscore I.T. 71 00:06:27,950 --> 00:06:33,200 and common socket and dot soc høst. 72 00:06:33,200 --> 00:06:35,410 Are you OK? 73 00:06:35,740 --> 00:06:39,980 So Høst or actually let me write in a better way. 74 00:06:41,030 --> 00:06:46,280 So here I'm actually going to use the underscore port. 75 00:06:46,580 --> 00:06:52,990 It makes more sense to make the whole server from the IP and the port and so we're already here today. 76 00:06:53,010 --> 00:06:55,250 So let's right now while. 77 00:06:57,030 --> 00:07:03,600 Through, OK, the prince waiting for the land. 78 00:07:03,880 --> 00:07:11,240 OK, then this right there, the common address next to not by paladares, but only address. 79 00:07:11,250 --> 00:07:18,120 So there are others will be equal to a circuit server. 80 00:07:19,860 --> 00:07:30,090 Not receive from and in the firm, and then there will be quote to daro that strip. 81 00:07:30,630 --> 00:07:31,120 OK. 82 00:07:31,530 --> 00:07:37,620 And finally last night, friends they received from. 83 00:07:39,620 --> 00:07:45,540 From Madras and this right that so it will be just the address. 84 00:07:45,570 --> 00:07:49,660 OK, and let's just please come before that so it understands it. 85 00:07:50,060 --> 00:07:52,160 You can see that we don't have any more errors. 86 00:07:52,170 --> 00:07:58,730 And finally, I'm going to print here message and then right there. 87 00:07:59,030 --> 00:07:59,390 OK. 88 00:07:59,900 --> 00:08:01,660 So, guys, we're almost there. 89 00:08:01,940 --> 00:08:06,950 First of all, here we need, I'm pretty sure, an equal sign between those two. 90 00:08:07,340 --> 00:08:10,420 And let's now make some exceptions. 91 00:08:11,090 --> 00:08:14,650 So if our code doesn't work, we're aware about the errors. 92 00:08:15,020 --> 00:08:23,530 So let's do respons equals high, then let's try percent s and percent. 93 00:08:23,730 --> 00:08:25,270 This is wise. 94 00:08:25,510 --> 00:08:26,840 But what for? 95 00:08:27,970 --> 00:08:30,170 OK, and then let's do. 96 00:08:31,730 --> 00:08:40,990 Except for the exception and then exception, us e and let me actually remove the same column here, 97 00:08:41,390 --> 00:08:52,140 so let's the response will be equal to or less than percent since DOT. 98 00:08:52,220 --> 00:08:58,160 And here I will use the option, exclude info and then it's right to zero. 99 00:08:58,610 --> 00:09:00,020 Then let's print here. 100 00:09:01,230 --> 00:09:01,640 Correction. 101 00:09:01,700 --> 00:09:03,580 I'm going to print on the same irritation level. 102 00:09:03,950 --> 00:09:04,880 So print. 103 00:09:06,810 --> 00:09:13,800 And then response and then response, and that's it. 104 00:09:14,100 --> 00:09:19,790 And finally, let's put another statement in this statement to talk about the response. 105 00:09:19,880 --> 00:09:21,540 Let's write response. 106 00:09:21,540 --> 00:09:30,300 And for just the person that is going to be liable for the response is going to be the one that is outside 107 00:09:31,230 --> 00:09:33,530 this exception here. 108 00:09:33,840 --> 00:09:36,570 So let us to hear a response. 109 00:09:38,170 --> 00:09:38,630 That's it. 110 00:09:39,250 --> 00:09:49,690 And after that, actually it on the same level, let's to circuit underscore server dot. 111 00:09:50,780 --> 00:09:51,650 Send. 112 00:09:52,610 --> 00:09:59,990 To and to illustrate the response, not in cold. 113 00:10:01,650 --> 00:10:02,340 And then. 114 00:10:03,860 --> 00:10:05,470 Address, OK? 115 00:10:05,890 --> 00:10:17,510 And finally, after we agreed with that list, simply right socket underscore server dot laws and let's 116 00:10:17,510 --> 00:10:18,700 just try the parentheses. 117 00:10:19,300 --> 00:10:24,910 So once the files are ready, guys, let's go back to our terminals and let's write quiz in the first 118 00:10:24,910 --> 00:10:26,080 one in here. 119 00:10:26,090 --> 00:10:30,310 I'm going to lunch with the UDP server, so let's write Python. 120 00:10:30,580 --> 00:10:32,830 So let's write here Python. 121 00:10:33,070 --> 00:10:36,580 And I did an error with the name, but it actually does matter. 122 00:10:36,820 --> 00:10:41,710 So let's do Python USPI even though to the server, let's run it. 123 00:10:41,710 --> 00:10:44,010 And here we can see that we have some error. 124 00:10:44,590 --> 00:10:46,030 So let's see. 125 00:10:47,150 --> 00:10:52,650 Line fifty seven or it's actually 14, if I'm careful. 126 00:10:53,060 --> 00:10:59,620 And here again, you can see that we have on there actually and let's see what there is. 127 00:10:59,990 --> 00:11:04,370 So I can see that here we need to have S. instead of C. 128 00:11:05,960 --> 00:11:11,580 S or actually here is actually a response instead of resource. 129 00:11:11,600 --> 00:11:12,200 So let's do. 130 00:11:13,500 --> 00:11:20,650 Response, let's have it, and so that is really here with the cold guy, so this is our client here. 131 00:11:21,150 --> 00:11:22,070 Let's try it again. 132 00:11:22,080 --> 00:11:29,400 So item USPI server your way and we're getting Canaro, which is not connected there. 133 00:11:29,760 --> 00:11:33,140 Obviously, we're getting that through because we didn't connect the server first. 134 00:11:33,540 --> 00:11:41,530 So let's actually go to the terminal and do Biton DCP server way. 135 00:11:41,790 --> 00:11:44,030 And if I run it, you can see that nothing happens. 136 00:11:44,340 --> 00:11:50,330 But let's run out the client and we're getting here already in use error. 137 00:11:50,340 --> 00:11:52,610 So let's see what the issue is here. 138 00:11:53,010 --> 00:11:58,080 So you can see, guys, that the server is waiting for a client and actually here to run the Klan for 139 00:11:58,080 --> 00:11:58,370 here. 140 00:11:58,380 --> 00:12:00,270 But I didn't do it. 141 00:12:00,270 --> 00:12:03,420 So Labor closed this terminal and terminate the process. 142 00:12:03,660 --> 00:12:07,830 And I will pull up on Arawa and let's go to the desired folder. 143 00:12:08,730 --> 00:12:10,160 So let's just see. 144 00:12:10,740 --> 00:12:18,570 So once I go for the right for in the terminal and then right away now it's time to run the actual client 145 00:12:18,780 --> 00:12:20,570 since the server is already waiting. 146 00:12:21,000 --> 00:12:30,360 So let's write Python and then you, DP client, OK, and now after a run, the client, you can see 147 00:12:30,360 --> 00:12:31,320 that I'm getting here. 148 00:12:31,560 --> 00:12:36,900 Enter your message, which basically comes from this statement here. 149 00:12:36,910 --> 00:12:37,960 Enter your message. 150 00:12:38,040 --> 00:12:46,260 Acadia's our input and if I enter the message high, then the server received a message from this IP 151 00:12:46,260 --> 00:12:49,950 address on Gispert that is saying hi and so on. 152 00:12:49,960 --> 00:12:53,130 If I sent another message, for example, what? 153 00:12:53,130 --> 00:12:56,970 So you can see that again, I receive a message here. 154 00:12:57,180 --> 00:13:07,010 So they are communicating through the port one, two, four or five, an IP address, 127 DOT 0.01 extricates, 155 00:13:07,020 --> 00:13:10,350 if you would like to experiment more with those who can send a few more messages. 156 00:13:10,650 --> 00:13:15,330 But I think for the purpose of this video, that's completely enough. 157 00:13:15,660 --> 00:13:20,460 And actually this was the last video from this section. 158 00:13:20,910 --> 00:13:26,310 So I want to thank you that you followed the discourse and discussion with me. 159 00:13:27,620 --> 00:13:31,920 Think very much for watching and I'm going to see you in our next adventure.