1 00:00:03,640 --> 00:00:09,760 All right, now let's run network programming with tons of it and we will learn about this circuits 2 00:00:09,760 --> 00:00:16,900 interaction and we are also building some small tools related to this network eye with Peyton. 3 00:00:18,470 --> 00:00:19,520 So let's get started. 4 00:00:20,750 --> 00:00:27,080 So these circuits are building blocks for natural programming, so any higher level modules will be 5 00:00:27,080 --> 00:00:28,020 using these targets. 6 00:00:28,280 --> 00:00:31,300 And Target is a pair of IP address and the number. 7 00:00:31,610 --> 00:00:38,720 So IP address is a unique address that defines a computer and that identifies a computer in this network, 8 00:00:38,990 --> 00:00:43,410 inalienable and no ideological book on which the service runs. 9 00:00:43,440 --> 00:00:51,860 OK, so this combination can be treated as a socket and this Wauconda transporter of this uh oh is a 10 00:00:51,860 --> 00:00:52,210 model. 11 00:00:52,940 --> 00:00:59,390 So these sockets establish the connection to this IP address and support and defines this how this transfer 12 00:00:59,390 --> 00:01:05,670 can be taken either to be a reality and we can communicate with the network operations using socket. 13 00:01:05,810 --> 00:01:08,450 This is the main important thing with sockets. 14 00:01:08,660 --> 00:01:13,970 We can communicate with, uh, the network applications using the circuit, even with local network 15 00:01:13,970 --> 00:01:14,630 applications. 16 00:01:15,980 --> 00:01:19,560 So many networking modules were built based on the socket. 17 00:01:20,000 --> 00:01:24,520 So there are so many modules and maps, Kappy and these are built on circuits. 18 00:01:24,530 --> 00:01:29,300 So this is a fundamental networking module for, uh, Saagar. 19 00:01:29,320 --> 00:01:34,790 Natural programming, even some models use the sockets in the back of the seat. 20 00:01:34,790 --> 00:01:40,280 They need to communicate with other networking applications so they need the circuits. 21 00:01:40,640 --> 00:01:48,850 So this socket is a very important and it must be done, uh, even by the normal pattern programmers. 22 00:01:48,860 --> 00:01:50,190 So it will be very helpful. 23 00:01:51,410 --> 00:01:57,290 So let's run about this, uh, some of the functions we need to use for the python circuits. 24 00:01:57,590 --> 00:02:02,500 So the concept is simple, but the syntax will be very easier in Python. 25 00:02:04,250 --> 00:02:08,420 So this is the server functions and these are the client functions. 26 00:02:09,110 --> 00:02:16,210 So before, uh, starting the server, uh, we need to call the socket function. 27 00:02:16,520 --> 00:02:19,070 We need to create a socket for that. 28 00:02:19,070 --> 00:02:24,030 We use a socket function and then we need to bind that socket to particular. 29 00:02:24,260 --> 00:02:24,920 But no. 30 00:02:28,010 --> 00:02:35,210 But IP address and what number we can also bring it to localhost or any other interfaces, so after 31 00:02:35,220 --> 00:02:38,900 reminding you you need to go on listening for incoming connections. 32 00:02:40,620 --> 00:02:46,500 So the father was start up and receiving foreign government connections, so whenever on the currency, 33 00:02:47,040 --> 00:02:53,010 we could all get in the same manner, all the service, but instead of binding and reasoning, we can 34 00:02:53,040 --> 00:02:53,280 act. 35 00:02:54,000 --> 00:03:00,420 And whenever we send we said to this server, we cannot use this IP address. 36 00:03:00,420 --> 00:03:08,220 And the number that is we use it here because the authorities are in a bind and it is on this IP address 37 00:03:08,220 --> 00:03:09,310 and phone number Switchfoot. 38 00:03:09,660 --> 00:03:12,870 And then we use the correct function to connect to this source. 39 00:03:13,560 --> 00:03:18,870 And then whenever there is an incoming function from the client, then the server calls this excerpt 40 00:03:18,870 --> 00:03:19,300 function. 41 00:03:20,580 --> 00:03:25,020 So up to here, the P2P driven handshake, uh, was completed. 42 00:03:25,530 --> 00:03:31,800 You, as you guys know, deceptively simple connect to the true handshake. 43 00:03:31,800 --> 00:03:37,410 As we know from here on, what we can start sending messages from to and from. 44 00:03:38,870 --> 00:03:45,220 So this model has seen that first plane sends the message, then said, what is this? 45 00:03:45,470 --> 00:03:49,500 And then it will send a message to the ground and vice versa. 46 00:03:49,970 --> 00:03:59,750 So then we can, uh, call this cross-functional to call this, uh, uh, connection. 47 00:03:59,900 --> 00:04:03,230 And afterwards, Sarver's target can also cause the connection. 48 00:04:03,470 --> 00:04:11,330 So the basic idea of this server and and the client is in this socket, we can, uh, communicate using 49 00:04:11,330 --> 00:04:12,790 this the socket functions. 50 00:04:13,480 --> 00:04:20,240 So first we need to run the server because without the server client, Karakoram to, uh, the server. 51 00:04:20,900 --> 00:04:25,700 So let's go ahead and program these functions and see how this looks like. 52 00:04:27,050 --> 00:04:33,130 So I'm using this virtually all with the record and I have created to and Grinder. 53 00:04:34,310 --> 00:04:39,120 So first we need to import this socket and socket module is built in the python installation. 54 00:04:39,590 --> 00:04:43,140 If you have installed this python and no need to worry about that. 55 00:04:44,030 --> 00:04:45,650 So import socket. 56 00:04:51,090 --> 00:04:53,360 So afterwards, we need to create this awkward object. 57 00:04:54,360 --> 00:04:56,460 We say, yes, this equals to. 58 00:04:57,970 --> 00:05:06,070 Soccer, but soccer inside this soccer module, there is a soccer function, so to that function, you 59 00:05:06,070 --> 00:05:07,360 need to pass two parameters. 60 00:05:08,200 --> 00:05:15,070 Those two parameters define what type of soccer we are going to create a TCAP or would it be an argument 61 00:05:15,070 --> 00:05:18,830 is to share the IP version for our version six one. 62 00:05:19,780 --> 00:05:22,740 So, you know, this is soccer, not a final score in it. 63 00:05:23,590 --> 00:05:30,550 So if I understand that this family and it represents the family of I'll be watching for this, it means 64 00:05:30,550 --> 00:05:37,210 that we are bending towards we are going to create a soccer that is going to result on that. 65 00:05:37,210 --> 00:05:38,510 I'd be watching for this. 66 00:05:39,190 --> 00:05:43,960 And second, uh, argument you want to pass is soccer, not soccer team. 67 00:05:48,150 --> 00:05:55,790 This is a big day for a package that is for Europe, you can also create a razzak as well. 68 00:05:56,200 --> 00:05:58,230 But for now, we are going to create this soccer and of. 69 00:05:59,010 --> 00:06:04,920 This is the streaming circuit and that is a Tsipi soccer because there is a connection establishment. 70 00:06:05,250 --> 00:06:09,540 So that's why we are going to create this IP version for and that is soccer. 71 00:06:10,620 --> 00:06:20,440 So now we want to say, yes, not a buy and we need to pass the IP address and the number as a couple. 72 00:06:21,090 --> 00:06:28,400 So put those brackets and share 127 dot 0.01 comma. 73 00:06:28,710 --> 00:06:29,940 Specify this point number. 74 00:06:29,970 --> 00:06:31,560 That's one, two, three, four AZAPO. 75 00:06:32,520 --> 00:06:36,950 So now my circuit has been created and successfully we are going to build on this. 76 00:06:36,960 --> 00:06:37,680 But no. 77 00:06:39,940 --> 00:06:44,650 All right, now, what we're going to say is we need to say, yes, that this. 78 00:06:47,540 --> 00:06:53,330 It is enough, we need to pass the number, so these numbers before that, how many corrections you 79 00:06:53,330 --> 00:06:54,700 want to suppose? 80 00:06:55,010 --> 00:07:02,470 Uh, if I say five here, I started it and then the third is for five corrections after getting five 81 00:07:02,480 --> 00:07:04,590 successful corrections, then stop visiting. 82 00:07:04,850 --> 00:07:08,030 We cannot count more than five corrections to discover. 83 00:07:10,070 --> 00:07:16,450 All right, now we need to say it's not acceptable, so we are accepting this connection. 84 00:07:16,880 --> 00:07:21,210 So whenever there is an excerpt, it will, uh, return the two values. 85 00:07:21,230 --> 00:07:26,030 That is the current descriptor, comma address. 86 00:07:28,240 --> 00:07:35,260 So this is a good descriptor and this is also Kosaka, if you are working with fighters, you say that 87 00:07:35,260 --> 00:07:37,760 the fire Cooper is opening the fire. 88 00:07:37,990 --> 00:07:44,410 So in this event, this is a soccer descriptor and we can perform the operations with this soccer descriptor. 89 00:07:44,650 --> 00:07:51,550 And this is not an exact function returns to very kind of, uh, the incoming connections object and 90 00:07:51,550 --> 00:07:52,600 then Darters. 91 00:07:54,100 --> 00:07:56,380 And you can just print out this address. 92 00:08:00,510 --> 00:08:08,220 So I to this is the first part and we will call for further, but for now, let's go to this grand and 93 00:08:08,520 --> 00:08:09,900 let's import soccer. 94 00:08:13,150 --> 00:08:21,670 And we need to create this socket in the same way as we created before soccer, not soccer stuff inside 95 00:08:21,670 --> 00:08:25,570 the soccer grass soccer match, the socket function. 96 00:08:27,430 --> 00:08:32,010 So we are going to create the same IP version four, and that is soccer. 97 00:08:38,620 --> 00:08:46,390 So now we don't need to write this binder or accept all we need to say is see that kind of stuff. 98 00:08:48,080 --> 00:08:50,980 And we need to, uh, pass the upper. 99 00:08:52,850 --> 00:08:58,740 That is one condition, not the right one, and the number is one, two, three, four. 100 00:09:00,710 --> 00:09:03,440 So I think we can send messages. 101 00:09:05,500 --> 00:09:16,600 So she said it doesn't matter and we can send our fight and we need to end this so important t you cannot 102 00:09:16,600 --> 00:09:24,550 send the strings, A, you need to encode this and this encoding will convert, uh, into the white. 103 00:09:26,070 --> 00:09:33,270 So important to you can send as a thing, but importantly, they have specifically put a rule that you 104 00:09:33,270 --> 00:09:39,040 cannot send in the, uh, socket or in the network you need to send as a by Sunday. 105 00:09:39,690 --> 00:09:44,770 So here we are sending the high and we need to receive here. 106 00:09:44,790 --> 00:09:52,730 So what we want to do is you want to set up so you want to receive the message from this Cranton. 107 00:09:54,090 --> 00:09:58,020 So that message is he to greencard. 108 00:10:00,540 --> 00:10:07,800 Currently not receive any specified number of bytes you want to receive, so two zero four two zero 109 00:10:07,800 --> 00:10:10,470 four debates are needed to decode that message. 110 00:10:10,480 --> 00:10:17,880 So it will be in a real format, like you will see the Russians and bees because the quotations and 111 00:10:17,880 --> 00:10:21,510 the format like that will be able to this. 112 00:10:22,350 --> 00:10:25,110 And you can get this one print off message. 113 00:10:26,790 --> 00:10:29,160 So now we can send a message as well. 114 00:10:30,100 --> 00:10:31,230 You can say Clent. 115 00:10:33,360 --> 00:10:40,680 Grindrod, sorry, Trent Lott sent off say hello, I am his. 116 00:10:42,230 --> 00:10:51,590 Sarver, I know you said that, and so you can also hear the new same message and you can assign that 117 00:10:52,220 --> 00:10:58,730 string to this message, but I'm just telling you, the syntax of these functions, don't worry, in 118 00:10:58,730 --> 00:10:59,790 the next few years. 119 00:10:59,860 --> 00:11:02,900 Well, uh, as I need to evitable. 120 00:11:05,700 --> 00:11:11,820 Now we are sending this hello, I am Savar to the screen, so now we need to see this same message. 121 00:11:11,820 --> 00:11:17,740 Is he to see that received at the same, uh, function syntax? 122 00:11:17,910 --> 00:11:19,290 You notice a number of bytes. 123 00:11:20,760 --> 00:11:23,960 Uh, and we need to decode this one. 124 00:11:26,460 --> 00:11:28,230 And again, this message. 125 00:11:30,780 --> 00:11:38,760 So now you got to see the message and we can see that close, we are going to just close this communication 126 00:11:40,290 --> 00:11:45,180 so we can just say first we need to call this a a good descriptor. 127 00:11:48,470 --> 00:11:50,140 Grinder, not cross. 128 00:11:51,140 --> 00:11:56,070 So if there are any other connections, then you need to cross those connections also. 129 00:11:56,330 --> 00:12:00,470 And then finally, you need to call this soccer for the soccer. 130 00:12:01,680 --> 00:12:02,380 All right. 131 00:12:02,450 --> 00:12:04,190 Let's review our code once again. 132 00:12:04,220 --> 00:12:05,240 We are importing soccer. 133 00:12:05,300 --> 00:12:11,870 We have created IP Version four and DCP soccer, and we are bringing it to this local host and one, 134 00:12:11,870 --> 00:12:12,290 two, three, four. 135 00:12:13,130 --> 00:12:15,740 And we are going to listen for five connections. 136 00:12:16,100 --> 00:12:20,210 Whenever there is a, uh, connection, we are going to accept this one. 137 00:12:20,420 --> 00:12:23,060 And we are putting the connection object on the ground. 138 00:12:23,060 --> 00:12:30,380 And the address address is just like this, this IP address and the number. 139 00:12:32,170 --> 00:12:37,240 And we are receiving the message first and we are painting that we are sending another message and we 140 00:12:37,240 --> 00:12:37,930 are closing that. 141 00:12:38,950 --> 00:12:44,930 So as long as as soon as this country has this message, it will it will close the connection. 142 00:12:46,090 --> 00:12:47,540 So let's go ahead and run this one. 143 00:12:47,710 --> 00:12:51,880 So I am running this news issue and we need to. 144 00:12:52,600 --> 00:12:54,490 Oh, I'm just going to open this one. 145 00:12:57,570 --> 00:13:07,110 So let me open this up in Britain ideally, so you can order to ensure the same results we got so far 146 00:13:07,120 --> 00:13:08,660 that we need to open another instance. 147 00:13:08,980 --> 00:13:12,810 Uh, but it's, uh, simple to use this opportunity. 148 00:13:13,410 --> 00:13:15,970 So let's go and run this group therapy first. 149 00:13:15,990 --> 00:13:20,790 We need to run this because without this, he cannot run. 150 00:13:20,790 --> 00:13:22,100 He cannot know that. 151 00:13:23,760 --> 00:13:24,780 So let's run this. 152 00:13:30,610 --> 00:13:36,520 And now it's saying nothing because it's going on listening for corrections. 153 00:13:37,000 --> 00:13:38,440 Let's go ahead and run this group. 154 00:13:41,550 --> 00:13:45,010 As you can see now, we have got the message. 155 00:13:45,030 --> 00:13:47,670 Hello, I am Sarva and the connection has been close. 156 00:13:48,210 --> 00:13:49,850 So this is from the claim. 157 00:13:49,860 --> 00:13:53,380 So great because we are doing already the message. 158 00:13:53,880 --> 00:13:55,920 So now let's go there and see what happened on. 159 00:13:56,970 --> 00:13:58,790 So we have printed this address. 160 00:13:58,950 --> 00:14:00,240 So this is how I dress. 161 00:14:01,290 --> 00:14:03,960 So one three zero zero zero one that is localhost. 162 00:14:04,590 --> 00:14:11,250 And because this model I have been running on my computer and then the board number so far, I drew 163 00:14:11,260 --> 00:14:11,880 Frassoni. 164 00:14:12,870 --> 00:14:16,500 So this spot is selected by the window scanner itself. 165 00:14:16,500 --> 00:14:22,090 So it will do this some random but random report and then it will use to connect to this or people. 166 00:14:22,680 --> 00:14:27,170 So that is the address dateable of IP address on the bottom. 167 00:14:27,660 --> 00:14:30,960 And then we are receiving the message from the client, which is right. 168 00:14:31,140 --> 00:14:32,190 And we are printing here. 169 00:14:32,200 --> 00:14:38,940 So we got the output right and then we are sending hello server and we are receiving we received it 170 00:14:38,940 --> 00:14:41,450 on the screen and then we are closed the connection. 171 00:14:42,660 --> 00:14:49,410 So that's about this basic communication establishment between the Clinton server is in the python suckage.