1 00:00:04,770 --> 00:00:09,900 Introduction to sockets, hi, everyone, and welcome back to the course. 2 00:00:09,900 --> 00:00:16,110 In this section, we're going to talk about sockets, which are one of the most important concepts when 3 00:00:16,110 --> 00:00:20,020 talking about connecting to different networks, specifically with Python. 4 00:00:20,190 --> 00:00:23,040 So a socket is the base of the IP. 5 00:00:23,610 --> 00:00:29,200 The sockets are used to connect to applications and make them communicate between themselves. 6 00:00:29,430 --> 00:00:36,360 You can imagine the socket as a tunnel between two applications that has a specific port name and so 7 00:00:36,360 --> 00:00:37,120 on and so forth. 8 00:00:37,260 --> 00:00:44,790 So using this to know one application actually has some bridge between itself and the other application, 9 00:00:44,790 --> 00:00:51,450 and then they can exchange data between themselves in order to have some role in the communication between 10 00:00:51,690 --> 00:00:52,980 those two applications. 11 00:00:53,100 --> 00:00:58,770 Of course, we're using the protocols that we already talked about in this and just sort of the FTB 12 00:00:59,400 --> 00:01:03,150 HTP and SMPTE protocols. 13 00:01:03,480 --> 00:01:10,050 Of course, there's our type of protocol that is used here, and you can find all of them online, of 14 00:01:10,050 --> 00:01:10,440 course. 15 00:01:10,740 --> 00:01:12,820 But these are the main protocols. 16 00:01:12,900 --> 00:01:18,690 We are going to be talking in this section and the main protocols with which we are going to conduct 17 00:01:18,690 --> 00:01:19,600 our tests. 18 00:01:19,950 --> 00:01:26,760 So in order for us to enable two applications to communicate between themselves, we, of course, need 19 00:01:27,090 --> 00:01:31,790 some type of components to enable this thing happening in reality. 20 00:01:32,190 --> 00:01:37,250 And for that reason, we created the concept of the server or the listener. 21 00:01:37,560 --> 00:01:43,710 So server usually turns on Eliseo's and listens for the communication on a specific port. 22 00:01:43,920 --> 00:01:49,000 And the port basically describes the tunnel is basically the number of the tunnel. 23 00:01:49,290 --> 00:01:57,210 So imagine the server as a machine or a virtual machine in our case that we simply turn on and it stays 24 00:01:57,390 --> 00:02:04,260 in a passive state until it is not awake from some other application that is calling on the port that 25 00:02:04,260 --> 00:02:04,890 is turned on. 26 00:02:05,280 --> 00:02:06,780 And here it comes the client. 27 00:02:06,900 --> 00:02:09,890 So normally the client connects us to the server. 28 00:02:10,170 --> 00:02:16,980 So while the server is on and waiting or listening, then we create a client that is awake in the server. 29 00:02:17,160 --> 00:02:24,570 So it calls a server or on the port that has been stated and basically starts sending requests and the 30 00:02:24,570 --> 00:02:27,770 requests you can imagine as messages. 31 00:02:27,780 --> 00:02:34,830 So it sends messages through that port to the server and then if the server understands these messages. 32 00:02:34,860 --> 00:02:41,010 So if you use the right protocols, then the server could respond with messages that are sent in from 33 00:02:41,010 --> 00:02:42,300 the server to the client. 34 00:02:42,540 --> 00:02:48,780 But usually the most important thing to remember here is that the client initiates the communication 35 00:02:48,780 --> 00:02:51,170 between the server itself. 36 00:02:51,480 --> 00:02:55,050 So we need a server that waits on certain port. 37 00:02:55,230 --> 00:02:58,890 And after that, we need the client to say to us. 38 00:02:59,150 --> 00:03:01,860 Okay, now I know that you're waiting for me. 39 00:03:01,860 --> 00:03:02,750 I'm here now. 40 00:03:02,760 --> 00:03:03,630 Let's communicate. 41 00:03:03,930 --> 00:03:05,730 And then the communication happens. 42 00:03:06,030 --> 00:03:15,060 Then we have, as I said, the trust transmission channel or this is the port or the tunnel that connects 43 00:03:15,060 --> 00:03:16,470 the server and the client. 44 00:03:16,470 --> 00:03:24,840 And we can say that this channel or tunnel or port you can go wherever you like, is basically an answer 45 00:03:24,840 --> 00:03:28,080 to a server and an exit to the client. 46 00:03:28,500 --> 00:03:36,180 So from the client, the signal where the messages exit from the client to this support, and then they 47 00:03:36,180 --> 00:03:38,700 enter the server through the same port. 48 00:03:38,850 --> 00:03:46,710 And finally we have the protocol, which is basically the topic of the conversation between the client 49 00:03:46,710 --> 00:03:50,240 and the server or the language with which they are communicating. 50 00:03:50,580 --> 00:03:59,880 So you can imagine the different protocols like the HTP or SMTP, as are different languages with which 51 00:04:00,150 --> 00:04:03,150 the application and the client can understand themselves. 52 00:04:03,840 --> 00:04:09,480 So if we talk about applications, there are, Trumaine, main applications that are basically using 53 00:04:09,480 --> 00:04:10,050 the sockets. 54 00:04:10,290 --> 00:04:16,230 The first application is a server, which is the application, as we said, that is waiting for connection. 55 00:04:16,430 --> 00:04:21,570 Then you hear the client, which is the application that connects to the server that is waiting. 56 00:04:21,690 --> 00:04:27,000 And then we have the client server, which are basically applications that are client and server at 57 00:04:27,000 --> 00:04:27,760 the same time. 58 00:04:27,990 --> 00:04:37,170 So when you run this type of applications, they are basically having internal clients and servers that 59 00:04:37,410 --> 00:04:44,280 consistently exchange information between themselves and updates on certain features of that application 60 00:04:44,280 --> 00:04:46,500 in order to provide you up to date data. 61 00:04:46,890 --> 00:04:52,710 So here, guys, I decided just to provide you a quick overview, just with three sentences, how the 62 00:04:52,710 --> 00:04:55,710 communication between client and server is working. 63 00:04:56,010 --> 00:05:02,220 And I know that I'm repeating this over and over again, but especially if you're new to the field of 64 00:05:02,220 --> 00:05:02,940 connecting. 65 00:05:03,710 --> 00:05:09,460 Different machines, it is very important to understand this concept before going into the actual coding, 66 00:05:09,820 --> 00:05:17,000 so always if you have any issues understanding about the processes that are happening in the codes that 67 00:05:17,000 --> 00:05:22,960 we were going to write in later on, please refer to the slide and read each of those three sentences, 68 00:05:23,170 --> 00:05:25,420 which are quite straightforward in my opinion. 69 00:05:25,750 --> 00:05:34,480 So the first one is the communication must be initiated by one of the programs, which is called Courland 70 00:05:34,480 --> 00:05:35,040 Program. 71 00:05:35,920 --> 00:05:43,960 The second program waits for the other one to initiate the communication and is called the server program, 72 00:05:44,140 --> 00:05:47,210 which is a program that is basically waiting for the client. 73 00:05:47,440 --> 00:05:55,690 And finally, we have the circuit, which is the basic topic of this section, which we have the circuit, 74 00:05:55,930 --> 00:06:03,250 which is a process that exits from the client machine and it goes straight to the server machine. 75 00:06:03,940 --> 00:06:10,660 In the main objective of the socket is that the server and the client read and the right information 76 00:06:10,660 --> 00:06:11,770 between themselves. 77 00:06:12,040 --> 00:06:18,520 Now, once you know what actually the sockets are and let's talk about the different types of sockets, 78 00:06:19,030 --> 00:06:22,830 because, of course, as anything else, the circuits have different types. 79 00:06:23,020 --> 00:06:26,450 And this is pretty much dependent on the protocols that they're using. 80 00:06:26,740 --> 00:06:35,980 So the socket that we're using here are going to be the Tsipi protocol sockets or the stream which basically 81 00:06:35,980 --> 00:06:43,130 uses the DCP protocol and provide security of the data transmission and security of the data reception. 82 00:06:43,360 --> 00:06:50,860 So by the transmission, I mean the data that is transmitted from the client or the server and the reception 83 00:06:51,040 --> 00:06:54,380 is basically the data that is received from the server. 84 00:06:54,790 --> 00:07:00,560 The other type of sockets are having asynchronous communications that is code. 85 00:07:00,580 --> 00:07:08,200 So did you run and this sockets are using UDP protocol and basically the packets of information here 86 00:07:08,200 --> 00:07:11,340 are travelling in the background type. 87 00:07:11,380 --> 00:07:14,080 But about this, we're going to talk later in more detail. 88 00:07:14,410 --> 00:07:21,180 But this is the basics about sockets and communication between clients and servers, guys. 89 00:07:21,400 --> 00:07:27,010 And I hope this lecture gave you a very good foundation for the code that we are going to be writing 90 00:07:27,010 --> 00:07:27,730 later on. 91 00:07:27,970 --> 00:07:28,780 And that's it. 92 00:07:28,810 --> 00:07:32,350 Thanks very much for watching and I will see you in the next lecture.