Transcripts
1. Socket Session1 Overview: And welcome to this. That is, the CPU DB socket programming or mingles as wonderfully knows, using bought C as well as C plus plus. So here in this session, I would be listing what topics we will be covering in this entire goals. So the metaphors, the optic, me will be understanding the basic concepts of socket for grabbing that this Amanullah it john related in order to understand though socket programming. Then, then next. And we've seen DCP architecture, which is also called as natural architecture, also goin as OSI model. So here you see water network components as well as we will see how the shadow in order to bring the socket communication. And we understand this with the real world example. Then the next session we will be seeing that setup, which is required in order to bomb socket communication for both windows as well as B naught. We will also see different socket functions, which is also called as methods for cyber. War declines for Windows and for Linux. And a slight difference in the socket functions for Windows and Linux, we will be seeing you have session, do understand the difference between Windows OS in order to bring socket communication. So we will be seeing what little setup is, therefore windows. And one bin setup is therefore Lena's. So how did they post what header files are required for being those who both on socket obligation and header files are required or Linux. Then we will be seeing what all different socket met parts are there whatsoever. And nine for Windows and robot socket manipulates our net quantity. So that is very slightly friends and the socket methods. So all of these differences we will be seen in that section. Then the next session we will be starting with socket program and we will also execute it. Barred windows as Venice for us. So here writing different programs. So that will be though program socket communication between server and nine. That is simplest cyber at nine Jack from negations we will be seeing and we will also execute them for those. And we will also understand others. Hockey program, o upon SCTP, Archie Cyberduck nine socket communication on the PC, Barbie in those aspects. Only knows and we will be also executing them in this manner, be building all these programs. Then the other session, we will be seeing what are blocking as well as what are non-blocking sockets. And even be writing that program or the scene and will be executing it in order to understand them more. But we will also see how to achieve my declines server. And we will be seeing that our different approaches in order to Obama, I think nine server's socket communication. So the first basic approach, drink what line do though? So you can understand that our clients, which one put on negate salvo and create multiple threads. So that radius decide one thes's and going through that approach. So we will see what are disadvantages are there in using that approach is not recommended to use NAT abroad. And therefore that I'd approaches which began in order to avoid those disadvantageous. So the next approach is to use Basilica. So even see what does select and what is its importance in order to achieve multiplied satellite communication. So people understand it more effective by writing and executing. But Linux operating system. Then we will see also the approach that is to make this occupies Nagasaki and do achieve multi-line I'm negation. So we will write the program and execute it in the nose in order to meet the socket as non-blocking and in order to achieve multi client server communication on so I have the source code for all the socket programs, the giant cohort in this entirely. So you can require, after understanding the food that I had explained sessions. So all of these things, we've already done this and dire cause. I have described it in short. So I had that like I've explained you what each session we're going to topics we will be offering indeed. So let's see. First session, we will be seeing the basics of the socket programming. So this session is dedicated to all amino law, these which are related for the socket programming. Understand the communication between server and blind. We'll be seeing what does socket, what do I type source socket is available. And in socket terminologies related to this domain and what is communication protocol. So all the terminologies related to the socket programming you'll be, you'll be seeing. But all methods are used for the cell wall and marble methods are used for the line in order to well ball socket communication between the server and client. So all the pieces that are related to the socket you'll be covering in this very first session. So this is very much rubric visit in order to start the socket of negations. So the next session is dedicated to the ECP architecture, which is also called as a negative or yard architecture, but still called as OSI model because very important session. So this, this issue. All the network that is netbook components which are required in order to bring the socket communication between solvent lines. So how come components will communicate with each other so that our seven Leo's presence. So compete architecture I have described here and in this session I have gone through lectures, but music foster coil will be listing. But by default this lecture will be distinct. The network layer architecture. So that will be seven components have been different network Leo's. So I'll be explaining you what is the purpose of each layer network IO. So this is very much B6 and you'll be finding it more investing. You'll be understanding how these network components communicate with each other in order to bring socket communication though with this information, with this already days in the first lecture, and we will be covering the second lecture of the same session, which I'll be explaining you that real-world examples and equity sinking with the network layer architecture that is TCP architected avatar of audio. In this lecture, you will understand another real world example, vid.net Leo. So I will explain you how these network components, how these networks play an important role in the real-world example. So this second lecture will clear your all concepts of all the seven Network Leo's of the PCP architecture. The next session that is taught session that would be related to the Windows specific socket sidebar client method. So here I will be listing defense socket server client methods which are used for the Windows operating system. So I'll be sinking it with the, so this is dedicated to that. The next session will be done. Linux specific socket server line against thinking with old. So here again the same thing, but this will be specific to the Linux operating system. That is very minimum difference between poets Rita use for cyber applying what windows as well as for the leader. Then we will be seeing the next session. That difference between the Windows specific as well as the knock specific socket programming Windows operating system. What are my thoughts are that immortal methods or net Bolinas and work on our differences are there between Windows and Linux. There are only few methods which are different. A specific form, Windows and Linux. And there is no much difference will be also seen here in this session. What our header files you have to use if you have two bulk arm socket programming for Windows Operating System and how it is different for Linux operating system. Then we will be seeing what are been setup is required for Windows operating system in order to perform socket programming, what is we build a startup is required, but Linux operating system. Then in this next session that a session six, I have Gvd Windows specific TCP socket programming in C plus plus. So here this, this, this is the basic socket communication between cyber and how will the charting takes place between server and client. And this, this will be seen for the Windows operating system. And we'll be writing the code in C plus plus. So this will help you to write the program on the IDE or doc ID VB using and how the communication takes place in be executing them. And the next session will be though, socket programming in C and C plus, plus what the Linux operating system. So that seems socket programming before the Linux operating system. And when writing the potency as well as C plus plus. So there are two lectures because I've covered in C as well as I have covered it C plus plus. So this is again the program. You'll be writing the code and executing it in for the Linux operating system. So in the next session that a session eight, maybe understanding a HTTP said line publication on TCP. So once you understand this, VCB communication misbehaved covered 467 session for Windows and Linux. Then you've entered, you will understand how this HTTP server nine can also be, communication can also be happened on PCB. So this is our gain, will be doing the program coordinator for before. In this session we understand poster called the concepts how HTTP Apache server communicates with browser Klein on their PCP. So I'll explain you, although things how Apache said what it communicates with client, that is whenever you are giving any link on the browser, any browser it can be, that is Mozilla, Firefox, or Chrome. Then how this request is sent from the client side is from the browser side to that HTTP Apache side-by-side, and how the server responds to this decline in form of the header. So all I have covered in this session, I want what that line does and who said what and how said what are they saying? That is spawns two plane and hold the page gets loaded. What wonder, whatever the user gave any link on the browser that this session will come meet or theatre all the concepts of HTTP server nine publication. So this may be if you go in sequence according to the session, if you bought new session 60, session seven, and then you will go to session eight, then this will be in you because so almost the programming is going to be writing for this. So communication will be similar. Meconium minimum V3. So this USB understanding ones we covered all the sessions and increments or though. So indecision in dedicate about back. Then the next session will be the same thing that about Africa. I'm disturbing about this stupid STDP Cedric nine communication. We'll start this session by VW bus specific execution of the HTTP Apache server client publication in C plus plus. So this cake is required prerequisites. So when you walk through the session, then only you should visit the session. Because this is the understanding how this communication takes place. And after understanding the communication and fanciful, then. If you are having Windows operating system, or you can write a code. What extra dB, Apache server. I have got all our programming and execution or how I should give you a B27 communicates with Klein is D plus plus. So we do the program for that and for the Windows operating system in C plus plus y. So the same programmed by for the Linux operating system in C. So depending upon what operating system you have, if you have Windows, you can go through this session. If you have a mouse, you can go through the session. Session. Given BC, how do I achieve my declines server communication using the socket in Linux operating system. So here, given a recovery while the c. So now very fast lecture, we will be forced what dark bucky as well as non-blocking sockets. Even the also the very first approach in order to obtain month decline several communication at this by using the select function. So even see what a select, select function, how it plays an important role and what ought arguments are there. So the next lecture we will see, we will be writing program and executing it in all using the select function in order to achieve my declines server communication in this man that I even understand all my client server communication or Sybil by that approach, by using the select function. Then in the next lecture, we will be using the different approach in order to achieve my declines several communication. And that is the second approach by making the socket as non blocking. So we will see how to use it. I don't need those are required after understanding this in the lecture three. Then in the lecture four, we will be writing the program and executing it by making that socket as non-blocking. That this thought in this lecture three, since even understand how to make the socket is non-blocking, Well, the eval function is used and what pedometers I used in this lecture by saying this knowledge of it bubbled in lecture three, we will be writing the program and execute them, making the socket as not bumping and how to achieve multi-line I'm negation. So this governing multiple programs in order to achieve my decline cellular communication by different, different approaches. Then last, we've been seeing the application of the socket. So he noted we're going to be seeing the AVR veterans socket cyber line. Are, you're unable to see the fin real-world examples wherein the socket are used. So now in this manner, we will be covering all of these session in this suit against CBR, accompanying each and everything on Windows operating system, as well as for the Linux operating system in C as Venice, C plus plus. So you'll be finding it more interesting. And it is explained with laptop program and execution. Depending upon the Lena's and rainbows. Your goals. I'm not, if you share your reviews as men, as readings as a means of not the meat and been influenced me to publish such on-demand videos. S-bar, your requirement. So Tank you friends. Thanks a lot.
2. SocketBasicsPart1: Welcome to this socket basic session, which is Betty, AS session of this entire goals veteran, I'm make you walk through different topics at is what this socket, what are types of the socket exist? What do I dominant logic are associated? Socket. So as to understand at the socket plug Rami ahead session and why this socket is required. What socket methods are available on Windows and wall? Socket methods are available on the units will be different. So let's start step-by-step. Moving to the very first topic, what does socket? Socket? It is a combination of the two nodes. But our next book, or you can say communication between the two processes. So let me make you understand through digram. Moving to the aims at an adult isn't the definition says socket is a communication between two nodes. So suppose you are having n4, n1, n2, and n3. And since it is a communication between the nodes or whether netbook. So let me name it. So this is one, this is three. And the communication between them, that is. And let us name this as to the internet. It's sold. What does socket? It is a communication between the nodes or wider network that is internet. So yeah, you can see here, we've paid this n1 and n2. These are the nine node and this node three, as I said, when no originally emitted or discuss detail about it ahead actually, so that you will understand what a sidebar, as well as what are the communication which takes place between node one and node three and node two and node is the socket communication is through this socket communication or whether national. So this definition that is a desert communication of blue nodes. You have seen audit their neck over the network. Again, see communication between two processes. So this can be done so processes, client process one, process two. And this is this I will close. Though didn't about deadlines. So what you see here, you will understand better. So he, I'd have dared out, although on the neck book, which is listening on the particular port and having an IP address. It is called as sort of one. So this one actually need the money. So he either side of a mechanism actually one should be listening on particular ordered an IP address. And either it should be sending the connection actually. So the one which is listening, actually this, the side of item mode and the one sending the connection. Actually there would be though client nodes. So these are the client node, that is node one and give it a sender and action, you know. And this North listening actually, so this fort as this side of it should be and this particular port number and it should have an IP address. So suppose you have, you wonder communication between different host machine that has different operating system, different machine. So you know, Prudence, if you are connected or whether it moves, then the IP addresses of dumb machine, some data dual boast machines which are connected or whether netbook much he'd been had one IP address and Adam achievement at that IP address. So if you want socket communication to take place, so one should be aligned, one should be subtle. So this side of art, which you may decide about, the mechanism is that it should be listening. It should be listening to particular port number as well as IP addressable. Human machine is having IP address. Each machine is having IP address. So it should be listening to, it should be listening to particular. You'd see all the mechanisms step-by-step. What is listening in detail and what is this IP address? What is this port number? So just to make you understand, just to visualize, making, visualize what exactly the sunlight as men as clients. So that, that is what I have mentioned. So moving to the next. This is an important note. Each processes that create the socket for the communication. The next point, the two processes can communicate with each other and he bent the socket has the same domain as well as socket type. So don't worry about this address domain and the socket type, all these terminologies and make you understand and further slides. So just understanding that more important or they say that this process is actually missing middle communicate. One to communicate over there. And they measured through the socket. You should have got socket actually created for them. So suppose no one thought that as a client node, have to dock with the southern route or what? This internet. Then we have to create a socket for this nine node. And we have to create the socket for the server mode. And the second about this is saying that if you are creating a socket for the nine volt, let us say node one. If you are also creating the socket for the software that is node three, then the type of the socket. And then presumably the same. So I will make your what is the socket type and what does the centers domain. But just toolmaker, no doubt that findAnswer, Why should have the same address dominates occupied. So let's see what does all of these dominant ideas about. So this address domain, which I thought in previous slide. So if you talk about address Doumani at our food types of dope. And assuming the first one is the unix domain description is that the two processes. But just sharing the common file system, the company gave him the address of the socket. It'll be the character string, which is then entry in the file system. So the address domain, which I've told that is first one is a unix domain though it's a simple thing actually that if the two processes over 90 to communicate to each other by stock will give it a become negating actually through the common pipe system. If he thought with respect to the isolated will be sharing the Scotsman via system. And the other thing is that addresses missionary, be that for this socket with a string data type, that this is about the unix domain actually. And I'm not good. Dipole, the address dominates that infinite domain. So V2, to be seeing this internet domain, you'll be using it, most commonly used actually. So in the, in the probe image and recovery recover unit embeddable miracles is most commonly used. So yet what will happen? Here? The two processes that are running on that host machine will communicate over the internet the same thing, which I don't know about. So that two processes say that node one and node three, because here the n1 is supplying node and the node three. So node, so these two nodes actually the uprising on different machines. And therefore they will become negated or what the internet, if they communicate what they actually meant it this coil, leon having at this domain on infinity homing. And the addresses of the socket of the is-a intended address was my seems simply to say that yeah, that addresses or this machine or that machine that is denoted by the event happening by IP address or IP address of the machine visited me at making a drum. And this set of item ONE, actually, it will have the IP address of the IP address of num machine. The satellite is running. So it is as simple as you can understand and this diagnostics. So V0, V0 making use of intended domain because this is most commonly used. So this is all about entropy data about their internet address will be on Kentucky group it. So this is all about this domain, which we have thought and this socket type. So we have seen in the previous slide actually the important note actually manual process that communicate with each other. Man they are having the same or destroy me and Saint socket type. So now you can understand that if the node is supplying node and node three is a set of unknown. And actually it may have to meet the communication over the socket using the socket between Norman and node v. So they should have the same address domain. So I don't know, should have actually that this domain as the unix domain, if it is having unix domain than 3D cellular known should also have the unix domain. And if you want the indented code, actually which I explained you, then the normal should also having dinner domain as an address. And the node three, there is a lot more detail also have envisaged albinism in dinner. So though they should have the same, either they should have, both of them should have units to me, or they should have, though, infinite. And the second thing is you'd thought should have the same socket right back to the node one and node three in order to vehicle communication over the socket. So let's see what does this socket type actually? There are two types of the socket actually. So that is a positron is just stream socket and the unfunded minus dot datagram socket. So let's see what is this stream socket. So it uses the TCP protocol. So this is a transmission control protocol. So what does broke apart epistemically the cycle, so that I cycled through once actually, which I probably did. So the TCP protocol will have set of rules actually enrich the stream socket will be or being. And yeah, the in-stream socket come it will communicate as a continuous stream of protector. So what, what is the behavior of the stream socket? By stonewall, it uses dark TCP protocol and communication activity either. I'm here, you see the sand actually, if you use Steam socket, therefore the communication will be bidirectional because once that connection is developed, in case of this stream socket continuously belt at a dustbin v3 transport. This happens in case of dots stream socket. And in case of the datagram socket. It uses UDP, is User Datagram Protocol. The entire message will be sent at once. So this is about the datagram socket. So let's see about this TCP protocol and UDP protocol, as I told you, don't look all mean set up rules for this TCP will be set doped roots. It is different than that of the UDP. And we have seen stream socket is continuous electoral stream or productive and be transformed wherein here with message will be sent at once. So now let's see what does this TCP and UDP. So once you see this, TCP and UDP will understand what is the stream socket which you need to be using, and what is the datagram socket.
3. SocketBasicsPart2: Coming to the communication protocol. So this is called as communication protocol, does UDP, user datagram protocol. It is also denoted in this manner that is underscored ins and this soil, that is what the diagram. So what is this you beat as User Datagram Protocol. So yeah, no, the whole message will be runs scored at one time. That is how much to eat in case of the user given input point. And it is not reliable. Because might is not reliable because suppose it is sending the data from one process to another. And suppose C nine descending someday dark windows server data isn't formal packets. That is num bytes. If some data is lost in between from, though neither do those set of OK. In that case, that will not understand as any lost in data from the client to server, and also the client will not be the same day damages lost. You can understand how it does. It is not reliable at all because he had even if the packet is lost, then one so the client will not again, San Diego said What? You've been on board that also collect the survey item o actually that these packets are lost. So this is called as an unreliable. And yet it is connectionless because there is no connection they've loved actually does not go connect actually to the side. But all the node point about this User Datagram Protocol. Because I debate Actually the reason it, this poster, while it won't have the Borden who do without connection actually, therefore, this reduces their time actually that ordered us into some connection. Another thing is that the packet is large, it will not send it a beam. So this is also one thing which will avoid their task actually. So it megacities in it is a lightweight because it wouldn't do such task actually. And also it does not do the editor checking. So that is the metal packets are lost than had been not again, sanded. It will not do though editor connection. It is simply the messages. It will not want that actually above the packet loss and there is no connection. So all these things, when you consider coined as a lightweight because all the stars, it avoid section. And it is also not reliable at all. But it provides broadcasting in case of UDP. So example, the live example of UDP I can tell you is the light multiplayer gaming. I didn't what happens actually in the data from sending from client to server, then this data will not be sand. Actually the reason actually incase of the multiplayer night game because this will, this will avoid actually that disruption or wide this backlog actually are again sending the message sender who received by this mood or affect the game if it is light. So to avoid such cases actually uses by UDP because it does not send the packet. Again. But the next slide, we will see what is this TCP transmission control protocol that is denoted by sock and the school stream. So Yarn poster boy, it will send and receive the byte streams of arbitrarily lead. So the streams will be sent directly from the sender to the receiver, from the client to the server, or vice versa. So the communication can be from climbed solo, nine, vice versa. Better, but we talk about this socket programming. It can be from one, from sender to receiver, from receiver to send or so I dream of the bytes can be send actually in case of this TCP and walk by Plato pipe you can see and the all advice to leave on the architect and delivered in order. So since this TCP be seeing it as a reliable, because by supporting the oil, older by instability in the correct format is going to be transmitted from the sender to receiver, as well as the order actually of the packets. So it's opposes. All data is divided into small, small packets. Packet one, packet two, packet three from the center, it will be sent to the receiver. It is from client to server. So in the receiver that is not said whether it will be the same in the same sequence order and the order in which it was being sent from the client or from the center. So therefore, it is very much reliability. As well as on talking about this ECP, Adobe's mass transient packet loss, it bacause. So don't connection set up and the maintenance. So there's no defined in one closes or visits, the connection or the connection breaks. So it's very much reliably actually some pictures lost. The other end will get to know that there is a financial loss. So also, it is reliable because if some packets are lost, again, the packets can be transferred from the sender to days. Receivable. A heavy weight actually, because all of these tasks that need to do need to resend the data of the data is lost. Then it needs to do the editor checking it sends a current data so that it has to do this while checking the error and rectifying it. So only starts got associated with this TCP. And therefore it is a heavy. So it does not support broadcasting and it is lower than that of the UDP. You can understand why TCP slower because it does this task actually checking the error of rectifying geared for sending the proposal, it, making a connection through the receiver, all these things, task, tactics, time. So therefore it is lower as compared to the UDP, but it is more reliable, more preferred actually depending upon the usage. So depending upon the usage, you can use TCP and you can use UDP. So when you are using HTTP venue or using HTTPS, you know, whenever you are visiting any site actually that is HTTP, using HTTP colon WW, bulldog bond lakebed, and never you give, invest that format. Then this HTTP or HTTPS that is more secure. If you add a HTTP. So all of these HTTP, HTTPS. Ftp, File Transfer Protocol or telnet. Actually all of these things actually they uses this ECP, that is transmission control protocol, and this is the socket V6 actually, now you study more about it. And also since MY dogged about HTTP. So I will also explain you at the very last lecture. Last few lectures actually will be having the programming actually of HTTP using ECB. So even that wasn't C. So simple server client communication using ECP also we will see other unpractical program of distributed using the PCP. How they communicate actually how the browser communicates with Apache server, how this communication happens. Http Slovak nine or whether TCP. So all of these things, we will cover it. So don't get confused. If you, if I talk about this domain and are muted MOOC step-by-step. So let's see actually. So I hope you understood what is this PCP and what does this UDP moving to the next slide. Now, this advice, so also the thing which I mentioned in my earlier slide that men decide when I'm playing me communicate if they are having the same socket pipe and the same address domain. So socket type you have seen stream socket. Server client should have either stream socket to communicate to each other or they should have felt both of them should have the datagram socket to communicate over each other as well as they should have the same. And there is a domain actually either independent domino still means either both of them should have in an unbelievably, either both of them should have units to me. So now coming back to that. Okay. Yes, this one. So decide by the end client actually during socket network application, you have different behaviors. But the general model for creating a streaming CQI, PCB, IP server and client. So what all this describes is that saying that the satellite implying actually we have to develop the socket for both of them. We have seen this in a very on your side also. Do they even have different, different sockets? Actually, if you want to communicate between them, Gaddafi applications or defense sockets are required. And both of them, and I'm creating the socket actually. The second thing that was socket method creation, actually methods or sediment in client socket creation will be the same. So this may even be starting next month. Visit actually different methods which are used while the socket for sedimented client communication, we'll see forming those work element occurred psi u, and in this manner you proceed. So let's see this side, webinar network methods which are used so their defense socket server methods and different sock socket blind network methods. Now let see. Now also in this methods and pretend you weren't all is busy quarter when goal machine, what role is present for Linux machines? So just engender to speak. Actually these net movement occurs which is listed for the satellite. Actually, sockets is almost similar and actually quite windows and pointy nose. Only Manon built one for APIs is not. Methods are not present. In case of the Unix list, all of them at once are present in KSR Unix. So let's see. So this socket side where network methods which are used. So what does it mean to be doing and no side avoided site actually to create the socket. Actually, in case of Windows. So windows, we have to initialize w. I will explain you what is a justice. I'm giving you the overview of what, what methods really using detailed discussion in the next session actually goes that and I explain you how, what is WACC, how to initialize it. So this is used to, this method is used in case of Windows. So this is not used in the Linux. The next moment that entices us side-by-side methods, which is a vigil had listed here. The next method is creating the socket for this initialized WSDL and supposed to be done while windows not bother you a Linux. But creating a socket is generous. So all these methods which are listed is general for both Linux as well as one minuss. So creating a socket, actually your degree at a socket on the software side, we have to bind the socket. So now this binder listen, accept all these unexplained you in Nevada lectures that are dedicated to hold action of explaining what methods are present. What I saw was eight and what all parameters? Yes. Opposed to pass to it. What is the functionality of each of them actually for the celebrate as Melissa Klein site. So by ending the socket, so but I have explained you that Panama said when he took lie, how communicate o the data offline. So why shouldn't listen to particular port number, an IP address? That is, you see this, bind, the socket means we have to bind to particular port number. Going with real explained in detail in the next lecture. And listen to those outside of vitamin B, listening on that socket, once it is bind to particular port number, it is any displacement on IP address. It is having one IP address. It will listen on that socket that is buying to decide what to listen. And then it will simply connected ones, that blindness AND connection, then it will exit the connection. So it has to do these task actually before accepting. It has to bind to particular ODE number. It has to listen to that port number and explain in detail. And then it has, then it is, it is a block accepting that connection, and that connection is accepted, then it is capable of sending the data to client and receiving the data from that mine. And another method is last method is disconnected us losing actually the connection. So this order methods, these all processes happens in gaze on the sidewalk outside, all found on functionality we have to do actually. And boy, windows extracting is we have to initialize Ws risks. These things are common to Linux as well as Windows completing socket to disconnection. Well, no, let's move on to understand to see what methods are there for the client side. Again, the same thing. We have to initialize Ws in case offline referred also. So this is UNEP on Windows, it is not applicable for Linux. We have to second thing, we have to create a socket sold streaming. I know socket creation. We have to do what the client as well as for the servo since these are the different application processes leaving him different different sockets. Created actually by, as I told you, four, said, What am I going to communicate? The socket should have the same socket data type. We have seen the socket socket type. Actually, it can be seen, it can be supported by Akos. Actually we have seen the stream socket types. You have senior friends, stream doc socket. It should be having either stream socket on either datagram bought up. The client and server should have the same socket actually. So we have to create a socket. So you can see in lectures actually how to create a socket, how to give this occupied or competitors domain. And then you will understand, then we have to connect. So as I told you this outline, the rule is to just connect to the soul will know how to connect with the solar. Because already the side of it is binding to particular order number and listening to that port number. So with the help of that only though I am will connect to the server. So don't worry about all these functionalities. Just I'm giving you an a what do you do deal? We'll discuss, you'll see in the next lecture which is dedicated to all these macro explanation. And then sending and receiving the demand such cutting through the salvo it escaped had been sending the data as well as receiving the data. And then the last one. So these are other methods for those and my site. So see actually these methods. Now we are done with the socket risks. So what all things Stephen be starting? This is just a null. What do you actually avoid topics we'll be covering Actually, in our row. We'll be covering the OSI model, that is open system interconnect model. This is going to be studying, this is a netbook reference model. It is very much important. It is called ISO network layered block diagram will give you the overview of all the network system. It simplifies actually, your road networks is complex network system into different, different components and describe how these components communicate with each other discipline ParaView. To also get rid of the problem does or you will understand how one day send actually hold the data sent from sender to receiver and vice versa in different, different processes, actually differently by different, different layer Bode diagram. What all things were dot O alleles comes into account. What are the different examples, protocols easily or uses. So this, I have simplified it in very easy manner actually. And this is very much important for all though. College-going students. Thought thresholds for developers, as well as it will clear your basic concepts simply to talk about it. In the next topic, which I'll be covering the sidewalk line and go socket APIs. Since what we have studied here at coincide available for window. So it was a client side for the socket communication that we will be studying in this lecture, you'll be sinking into the Cold War. But ME does what all functions are used in detail. And then we will study what is said about line Linux socket method. And then we build a program for PCP, said about nine socket communication on the board, but you'll be writing the program to communicate. Between the friend forced file using this TCP protocols have of mind and we will see how they communicate, how server communicate with Ty and help. I'm will send a message to server. Howsoever will respond to that line. So this, we will do the practical example, right, but program one by ID and we'll run it. So the next thing, which will be another thing I thought actually this is very much important. So that is a reason I will be covering with its programmable. So since I told you what is HTTP, it uses TCP. So even see this program actually, we'll see what does HTTP and the programming of STDP, so-called encore block ID. So you can understand what is HTTP site of autumn. So you will find it more interesting because day-to-day life. Now the internet is becoming so common to all of you that we are used to it actually be have simply something we have to find actually be available through the Internet. Achilles soldiers always have this thing you will be aware what is HTTP? Simply give HTTP colon or name of the site actually, which you want to visit. Level explained you how the browser communicates, how whatever you give the site name actually on your browser, that it is a Chrome browser, Internet Explorer browser. How it talks to the robot actually idiom how it fetches the data and how you get there. Guitar, on your application level, you write the program actually with the help of the knowledge we have studied, the breeders lecture, identify you as very much easy. Once you just have to start with, you have to write the program with me. And you'll understand embryonic Lecture seven, given what I blocky as well as non-local sockets. And we will be writing a program and executing it in order to understand them much better. In the next lecture, we will be seeing how do achieve multi client server socket communication. So nobody forced to be sick approach using the thread. So that I say everybody said one pieces by using that. And we will be seeing them one by one. What are there in order to avoid those disadvantaged person approaches in order to achieve a decline server socket communication. So here I have divided it interdependence and lectures in order to understand how to achieve my declined server socket communication. So there are two approaches. So in this lecture, we will be seen by the first approach, that is by using the select function. And we will be seeing what is the select function and how you use it, what all humans are required. In this manner, you will see how it brings my declines socket communication. So this lecture is dedicated for that. Then we will be writing the program in the next lecture, the program by using the select function. So here in this lecture we will be understanding what is select function, how you use it. In lecture nine, we're writing a program and by using the select function on the Linux operating system. Lecture ten. Achievement decline server communication by using the second approach. So even that second approach is by making the socket is non-blocking. So we will see how to make socket is non blocking. What all functions are used and what are humans are required. So with this information in lecture, then we will proceed further or lecture lemma that a new write the programs and will be executing it by using the second approach by making the socket is non-blocking. In this manner, we will be seeing how to achieve my declined server socket communication and an inverse operating system. Then the very last lecture, we will see the application or socket. In these areas, socket server, client are used and we will be sinking it within real-world examples that all the socket servers are used. So all these things I have mentioned which we'll be covering, and I have made you walk through all these socket dominant ideas, what all things are necessary for the socket. So VI done for the very first lecture of our compete school socket V6 next BOD POD, this lecture which I have mentioned actually, that is, so this OSI model, net volt reference model, denser, multiplying all these things you will be covering step-by-step. So thank you. Thanks a lot.
4. SocketSession3 Part1 TCP OSIModelPreview: Hi, welcome to the second session of the course that is TCP IP architecture, which is also called as all as I model. Dag is open system interconnect model, also called as network reference model. This will give you the overview of the networking system, explaining you how these components will communicate with each other, how to be transmitted from sender, receiver and this middle basic, your socket unzips DM, So networking. So let's understand these networking and let's understand how become negate. So you will get an overall picture of the socket and its internal components. The, Let's begin leaving the BC, or one of these topics which is mentioned in this slide, that is, what is OSI model and the importance of it. Blog diagram of OSI model B. Then a discussion of the components of this architecture illustrate, illustrating the communication of these components with each other. And finally, we will be seeing real world example to illustrate this OSI model, to illustrate how these networking components communicate with each other. That is the OSI model, which is also called as networking layered architecture. That is also that TCPIP architecture. So let's start with my mom and understand this networking system, how these components communicate with each other. So what do you do in the next slide? What is OSI model? So OSI stands for open system interconnect, which is also gone network with reference model. So this OSI, it will give you the overview of the entire networking system. So it's an oil is to simplify the networking concept into small, small network components and to describe how these network components will communicate with each other. So this is very much helpful him. Or the network techniques Jian Wu troubleshoot the networking problem because it simplifies this negative when they're hoping systems and do small, small components. Explain you how the art of communicating with each other. So that whatever your problem is, that you can troubleshoot which layer this problem occurs and you can exit. So this is how it simplifies it. So this is what I have described in this slide. The another point is that what I mentioned earlier only provide you the overview of entire networking system, but also simplifies the problem of network technician. Who isn't it troubling problem referring in this OSI model, it consists of seven layers. That is the seven components like see what components are present. Though very upper component abelian, which is present in this OSI model is the application layer. So this detail I have described to you, don't worry, I will explain you. What is the application near what is present, all these nodes one by one. And we're going to be seeing also what protocol and status set of bullets all these Leos are using. And later on we will also see how the OSI model view in sync it with the practical example. I will explain you real-world example. And I will explain you how these Leo's bringing the data from sender to receiver. In fact, examples of human understanding. So let's see.
5. Socket Session3 Part2 TCP Network Layered Architecture OSI: This is an application layer that is very topmost. Leo then is the presentation layer, Session, Transport Layer, Network LEO, data link layer and physical layer. So all these things I have described here with the examples actually, but lets see one by one. You can go through it later on and whether digraph, That is architecture. So let's begin with that up earlier. That is application deal. So what does this application? So it provides the user interface. So simply evenly talk about application you can understand application is the one which will help you. Step one, arbitrary user will interact with. So it will provide you the user interface. So whatever action you fall, fall on the application that will be reflected, then it will reach the lowest Leo from topmost Leo. So you use a need to do some action in order to get the appropriate response. So that action which is done, is done on the application component that is present. And that is, that is what about application Leo examples or FTP? No, FTP is used to plans whether phi. So ten net also, you know, we have to connect email applications or other applications. The order is defined. Then the next layer, which comes as a presentation, DO SO what does this presentation Leo? So in this presentation, Leo, whatever I'm motion or data conversion is required in this application will take place on the presentation Leo. So simply decide described here also. It is used to the format the data. So you can compress or decompress, encrypt and decrypt. But Gita, since study deconvolution is required, therefore, it is admin form under Deepa will come 50 companies and Paralympic group. So yet, whatever the formatting the data will be taking place. What application when taking this presentation, Neil and the other data encryption takes place, as well as character sect and wasn't explicit. So example also there. So JPEG, PNG. So you know, these are the hormones also their fixed format. So these are different, different type older format. So you can understand this example itself there TO data encryption takes place data and voyage and takes place in case of JPEG PNG. Yeah, these are different formats. So when we talk about the data format and this presentation layer comes into a gun. So don't worry, I will explain you the real-world example after explaining these layers. And you can sync with all these news. That is presentation, application in oil and in this manner even understanding what really then what is session NEA, session layer, it will write the name itself, says that is the connection you can understand. So it opens and closes session with that company mouthfuls, so it is responsible but opening the session for controlling the session, foreclosing the session that remote post-doc is done in war machine. And so this session, the OED actually, so this session, which of deadlocks that anymore, who knows that is a connection Richard develops with the remote virtual connection. So it butchered by the name itself. You can understand it is not real connection actually need some virtual connection. That is established, so also described as a transport connection less or without any network communication. So you can understand that an ancient exists but without any network communication. So therefore the name watching connection, then the example of the session layer are given, explained you actually, that is, that will illustrate use all the email application. So in the human application manner role, we have to send any funny Buddha remote host. We have to transfer the Pine To the remote host. So what happens at, though pretty pre-established, there was but a CBO bill send the data to the sangha of telling the information about how much the data is received now. So it's one small intervals whenever the file is being transported. In case of the email to the remote host, this receivable tells the sender how much the data is being transported. Now. So that happens at small, small and governments and 3h assemblage and double suppose in between or needle connection gets lost from there down. So that we have not discussed above or below this session layer that is a brand, that is a transport layer. So denote we have discussed about the application presentation and nomial talking sessions. So below procession near that transport layer. So if the connection from the DOM layer, that is transport layer, it is lost, then what will happen in that case? In that case, the watchman connection will be existing. So what you'll connection will not get lost. And an inverter, this session, the audit receives a new transport connection, then sending on the data. Again, extra resume from Reddit was stopped earlier. So this I mentioned he also basically the opening controlling and closing session. It is done by the transport layer which is downward to this session. You can understand what is the session near the spine needs to be corrected spelling. Now. Then when we talk about Euler rotation via so now talking about the DownloadActivity, thinking with the session, we also draw on what is the transport layer. Transport layer. It will transfer the data by the name itself. You can understand, and it has an inbuilt, blue-white, any connection between the host. So it will transfer the data and provides end-to-end connection between the host. So this transport layer, actually, you can see the connection between tablets between the host can be reliable, that is an action or can be unreliable. They're disconnection that soul. I hope so by this reliable and unreliable, you might be understanding we have seen in the reports searching about TCP and UDP, met and B have seen PCPs reliable. Europeans, non-black is unreliable. And we have also seen that TCP is reliable because it is, it will ensure actually all the data is. To the receiver correctly in the correct order that ooh, if some knob I can dislodge, center will notify to the receiver and again the data can be transmitted. So editor predictions also provided it is heavyweight level because all the wood walls in task one error correction for sending the data if the packet is lost and it develops a connection. So all these things happen in case of dough TCP is a reliable connection. We have seen unreliable connection. That is, that is UDP had no error, correction will be banned. And it is not o, it is best onboard that even if a packet is noisy, not send a data and not notify once you do that, a CBO. So here it is very lightweight. So all these points we have discussed, all this transport layer with the help of their families because are linked to each other. You can see when I talked about the session neared, I was here was what was walking with this DOM near transport layer. Ok. So now because they are communicating with each other, nominate talk about transport here. Nobody who coined his pension that Hale-Bopp network here. So that is again there w. So this transport layer with the help of this magnetically ordered his own IP address, and it builds Sander data. So though data widget receives vigilance transport layer, it receives from the session layer actually it, with the help of the download that data, it will address the data. And so the example which I told you is TCP data connection one and UDP is connectionless. So the next layer which is present is the network layer, which is the downward through the transport here. So what does this network Leo? It is it is it routes that is ramping means giving their direction. So yeah, DO data packets on details Transport sold out means to giving the direction to that packet to which path it should be travelling, that packet should be traveling, so it will be rounding. Datasets will give their direction, will give the RP packet from one path, it should travel along descended to policy, but that this route, so it will, it will, it will again reassemble the packets of data because it sends one packet of the data, one few packets of data from sender to receiver, CBO site, it will reassemble, it will collect all the data together. So this is about the network view. So the main purpose of this demo nuclear is also addressed the packets. So it had been provided their address to the packet, right? That that packet will understand actually through which path it should travel. And through the internet, local bridges and uncle and example is IB. So I also understood this. So it will roll is actually to give direction to the packet that is ramping, name reassemble the packet of the data. And its main purpose is to give the address to the packet so that the packet will understand who which they should pass through. Internet, local bridges and auto example is IP. So the next layer is there data link layer. So what does the data link layer? It does actually, so it is also the next one driver layer using. Because by Dr. Willard because it will also neglect art is a hydrostatic. This is the main network guide which through which you achieved the internet. So this is our device through which you achieve and collect. So it is this, our Leon is not a device, a desert rivalry is a network tribal and because it will control the network card, okay? Now, this data link layer, I need the competitive request as two or more negativity or uses soul, since it will control the network card that would've been an eagle and soda connections. So they're never that or more neural network layer which is using the same network answer your non-equity oldest present at top of this, which we have discussed now. So then do one word, network. It will use the same network card. So how this management when for the White House has access to the network guard will be that is only my neck and network card. But how this excess money provided for the network layer which is present and Egypt and pulling this data link layer. And so he, I don't also the physical addressing of the network and action takes place. It also consist October law about disorder will have described so that you should be knowing each and everything about the CEO. So it comes as to which topology there is internet topology. And it is also used, it also uses are most commonly used network device, that is if uses switch. So this is all about the data link layer. Also does the Italian clear it consist of two sublime, isn't it? So widely otitis, media access control, that is mac sublayers of what does this Amaterasu, It is responsible for the device interaction. This I mentioned your device networking detection. And the second is W at which does Dayton in Kansas, is logical link Leah, suddenly. So this logical link layer, it provides multiplexing and addressing about it. Though we are multiplexing means what? It means. It will, are now, might deepen and walk through appropriate why people exist at different multi-point network. And it can also be transferred, transported, or whether same networking medium. This is what about the multiplexing? So an example of this data link layer, if you see will be the mass source and destination address, as well as the eternal flame. So don't worry about all this. Technical writer, poet is doodling clear. I hope so you understood, just understand it. Going through the network part, it is used to meet an angel connections when I'm when people connections from the network layer using the same network card, it will manage that connection and it fancy store two things present in our debtors, MAC and LLC. Logical link control magazine of a prom is divisive that action and this will provide multiplexing and addressing. So their detail about it, I'll explain you involve real-world example, which I have a lot of the public, these leaders, I have covered the real-world example and I'm explained holders, these Leo's, the sync actually what they will do when I'm in that real world examples. So you will understand what exactly these Leos are mobile. Now, the very last layer is the allele. So this physical layer, it is also called as though it is a network. Also doesn't mean Hyderabad actually brings the network that are different forms of heard of it. It can be also the network cables it hadn't heard and all that. So all these concepts that physical. Yeah. So thank you. Thanks a lot.
6. SocketSession3 Part3 TCP OSIModel RealWorldExample: Hi, welcome to this second session, Part two for this OSI model that is TCP IP architecture. So in fact, in the same session I have discussed about the seven Leo's, which brings the networking system. So how these components, what are these layers are responsible for? And how they communicate with each other. So in this lecture, I will be explaining you that he and God example. And I will be explaining you how these seven Network Leo's video rolling the sailboat examples so that you take a picture how these network Leo's network components one day I had and how they communicate with each other. So let's see this. So here we will be studying the inward examples like this. I simulate a single food order. So yeah, the customer will not make not through their network and place an order with an IPO. Then we will consider that dog customers calling done on both on their distorted and placing an order and that person know, deceives decoy and the customer communicated with the order details what the customer wants. And delivery person then will be going to the address on a stimulant and going to be delivering food. So it will be to see how these Leo's then play a role in them. So let's see a one-by-one. So pastas application, Leo. So Vannevar stellate is submitting a form for silica stoma is interacting with the horn actually do communicate in the details of the order. So yeah, the application so you know, what is the application layer whenever that is an indirection, it allows the user interaction, depending upon this action, it will be responding. So the action is that the customer is making a phone call using the phone to please order. So this is, this, the application layer comes into account and the protocol associated with it are HTTP or HTTPS, then that FTP, as I said, is empty. So all these are the protocols which comes in this application layer soda, customer, using the phone to place an order untimely application. Leon, let us do that interaction with the port. So then next comes is the presentation layer. So what this presentation the IB has studied in the previous lecture, what does it do? It does the form I think, of the data. So it will do the data encryption. So it avoided the formatting required for an application and be done in this presentation layer. So what did we do? Blastocoel or the command which it receives from the application layer of policing. And on the back, it will be unloading the human EVA suit event non-network formula. So what does it mean? It means that definition means that it reporting into some particular format that you said. I understand. So this format should be common to them. So here Similarly in case of example also whenever the asteroid one foo, I'm going to get of the order details like suppose the customer wanted to order some nought. So it has to communicate to that restaurant in person. The language which no customer is using to communicate to that this burden present should be common language. That is, it should be universal, it should be known to them. So that is a reason it will be converting into that format. It will be converting in perfect language. Speaking. The person will be speaking in that language, common to both of them. So that miseries and this presentation layer, it is used to unmoored in that format that is understood by them in order to pack all proper communication. So this gums in this presentation near the protocol used is the D. So we know that the images in different formats, the date back if Pfam NGI bend at our HTML different, that is the page actually the webpage, then the ascii related to third strings. So this is on the protocols which are used here in case of presentation Leo. Now, this session, what does postal cuando session layer do? So in order to transfer the data, that is a packet actually do their destination, this session layer, it should open control and close this session which are there between the end-user application processes are responsible for opening, controlling, and foreclosing decision between different application processes. So Riot is required open-ended session. Do the remote host in order to send data to transmit a packet, it should pass open session, do that remote host. So we know this session near US and what you can actually have seen butanes and abuse through this lecture or this session, second session. So if you this example, Victoria Albert example, by stockholders, customers making a phone call and the restaurant person should receive it. Actually, write your receiver so that the customer can communicate with that receiver. This disorder is dead and unique, new send this ordered. So this communication is required so that receivable again, the information of the order details what all order the customer has faced. So this on because the reason the session, this is very much required. The other end, that is the distorting presenters received a phone call or in order to have this complete successful communication protocol used as RPC, you know, RBC. We have, whenever we have to come communicate through the remote machine actually then that means you need to develop a session between the remote machine. Then this RPC used SQL also do communicate with the database actually to connect to their database. Sql is used, Network is one and it working prices temp one. And this X Windows is used to communicate or whether I gotta get machine. So this is on the session layer comes into account. Now talking about the transport layer. So cluster while the transport layer is to transform the data in between end-to-end. Can it brings out the end-to-end connection promise. Was there the mean also what this transport layer, when it does, it, does it is, it not only ensures how the data should be transmitted, like whether it should be connectionless. Audits should be connection or data that is, TCP should be therefore, an ancient UDP should be therefore connectionist, inorganic side packet all its sole provides no fireball security and validations and provides a security that is acquired one, please. So you know, by N1 is used to secure their data. The suspicious package that is. Which is suspected at some problem with some editor will not be passed to the higher one. So I need a valid packet will be passed. But suspicious bracket, non-key parcel, it provides the buyer wants security. So with deciding how the data should be transmitted, connectional connectionism also provides these features. Then. It also brought there does it provides a quality control? Quality control in the sense. So this has Species packet will not be allowed to pass through the fire. And was Susan's depicted problem is there in the packet. Therefore, it is checking the quality of the packet is not good, not deliver through the firewall. That is the reason it provides this quality control. Now, thinking with a real board, that is, if the food is not good actually, which is being prepared is that I started and it had been an RB deliver to the customers. So this a species four will not be allowed to be delivered to the customer. Thinking with a real world example. So this, as I describe you, this transport layer ancestral two things, two types, statistic, Cp. Here, it will decide that how the data will be transmitted. It will be having an action, it is connection oriented. It will be also reliable that because if somebody dies laws then it will be notified to the receiver also again, it will be transmitted edit that section will also be happening. And this is how Holzer deserve heavy bait because it performs all these activities. Then example or PCBs, HTTP, FTP, SMTP, met as in case of UDP, is connectionless oriented, we have seen that it is not reliable because of some packets are lost and it'll be not notified to the receiver. Again, it will be not send reset. And it it does not bother that it was not directed. So that is a reason it is not reliable. And the life example of this UDP is lying vertically or gaming. So this is some notation that is multi-player. So right, it does not send the packets which are lost because that will be our disruption. In this communication. Again, DWB, WB senate sometime will be taken. So that is a reason or not. It's ended and therefore it should be used in live communication. So this is what happens in case of UDP. So this is a live example. Now talking about them o'clock Leo. So what does this network layer we have seen first took one network layer. We have seen in the earlier lecture, provides routing of the packets. That is, it will decide what direction the packet should go, ooh, what path it should follow. And then we have seen, and we have also seen it is responsible for framing and assembling of the packets. So what neck multi-year provides, it provides the best path to route packets. So best part means it provides of what should be the best path for the group level bar chart, short path. Before actually in order that packet should be sent from the sender to the receiver. And what part is should use, what is a valid OK, so at that point at this coil is a s-bar route the packets. So what is done yet? Routing is done. Giving their detection to the packet will walk audit suitable, and fragmentation is done and reassembling or packet explicit. We will discuss all these things are Fido. So now sinking with the example here, if we see here, so the delivery person who will be delivering the food to the customer. It uses GPS, Google map back this way. Responsible to bring the shortest paths visible bought. So who better map for whites are very short, shortest spot. And this is how it syncs with the real world, this network, real Leo, BEC, and sing with this needlework. Now are the three steps of which I have seen what, what all these are rounding fragmentation reassembly. So it does describe here indicate so logical addressing posts. So yeah, these are the virtual addresses. So that it will be a virtual addresses which will decide what how the packet bought destination would be there. I know I'm done or do you send a packet? That packet will be going through the network. So we're going to be now between the networks. So these are the watchin addresses, that is logical addressing which will take the packet to route through the network to reach that destination. So yeah, IPV4 odd IPV6 protocol is used, so does use to simply his other virtual addresses, which will decide what destination will be there so that the packet will route you wouldn't read today and we'll be using this protocol. And thus I can process second step in this Viterbi data encapsulation or our verbal encapsulate this data with their, with the source and destinations. So there will be addresses associated with this data source and destination because as I told you, it is used to route. It will give the path was to appoint what parts should be reported. And it will also see that it will be having a source and destination address also, so that the data will be reached through its final thoughts, source and destination. It will be sinking with her. And then after segmentation resembling so here, endocrine stage of entity. It will be first of all, isolated data spots, then it will be assembled it, and then we have to assemble it. So empathise very much notch. So it can happen that the one-day ties all these datas pleasant in non-contiguous locations in the memory. So what, what did we do? It will be fragmented. It will collect all these data from one computer's location electrode. And it will collect sizable Jiang saw what size it should be grounds for. Depending upon that, it will collect that data which is present in different, different memory location, and then the data will be transmitted. So this is about fragmentation. And the protocol which is used here is though, that are now being information protocol because yet pumping is done in the snow in this network layer as well as Open Shortest Path First, because it proposes that shortest path, this protocol is used here. Now I'm going to download their SDK and include. So this is what does this data in England, as we have seen, it is also goiters over the network. It is used to control the network card. It is used to manage the Mordor mood connection. Is that from the upper layer and that is the transport layer. That is one the negative locally or to use the same network, then it will manage it you have seen in the previous lecture. So what this data link layer do, it ensures that the data will be transmitted without any editor. It will do that part. And also we have seen, does the Italian clear answers talk to somebody who has we have seen advances talk logically control and also media access control. We have seen oneness and that logic control that we have seen in previous lecture that is used for multiplexing and addressing and media that is marked as used for hydro. It provides advice and direction. So these two layers, what David do, Sebelius, which they will also provide the success for transmission of the data. So all these things are associated with it. So he had it been, have this li and we'll have the Mac physical address, which will define the destination address where the packets three. So what does the endocrine system, the MAC address. We have seen this magnet is a physical action, physical address, which will help that person who reach to the destination. So this is very much important. And so UDP segment example is their destination, physical address, or the customer delivery person. Knowing I in order to help food estimate. So it said to seek physical destination, physical address of the customer. So now the protocol used here is Ethernet and point-to-point protocol. They're now going to the very last layer, that is the physical layer of 70 have seen network card or the metro cables. All these comes under this physical layer because it is linked with the hardware network part of it. So these are the components. So obese, the customer who's feeding comedy, comedy would place the order. And he said, We will consider to becoming another physically on the customer's reading, one of whom. So this comes on metaphysically agree through this course. I've been low if you share your reviews and ratings as it means a lot to me. And when influenced me to publish such more on-demand videos as per your requirement. I'm done for this lecture. Thank you, thanks a lot. In the next lecture we will be seeing windows rocket methods and enough socket method so as to bring the communication of the socket. Thank you friends.
7. Socket Session4 ServerClientMethodsWindows Part1: Hi, welcome to this new session, that is socket server client methods for being both. So in this session, given BC, the below topics that he owes, other topics which I had mentioned, we will be looking into the environmental setup at this January for both said about M client socket. So this is the same Goleman building Waterman Center required for both server as well as client socket. Then we will be seeing the adoptive topic that is, the median would be discussing Garmin efforts are the APIs that the January cohort server and client. So there are three methods that are to be API's retarded only for both hardware as well as client for the Windows operating system. So we will be seeing is three methods. You'll be seeing what is the purpose of these three methods and how they are used will be sinking in the chord. So this session is very much required prior to the socket programming process, but inclined for Windows, Windows operating system on IDE. So before executing the code, before running the code, we will be understanding the mappers, the functions which are present, and outlines socket so that you will be getting a better sense of what we are doing and it will make you understand in a easy manner. So these are the methods which are vividly discussing. These are the common methods required for both server and client. For Stephen, be looking into these three methods, then we will be seeing next. Decidable socket methods are APIs that will be specific only to the server. So setter methods which will be specific to the server that will be seen sinking with the code. And then we will be seeing the client socket methods that can be specific to decline. Again, thinking with the goal. So this is what we will be studying in this. So it is very much must in order to start the programming for settlement and light. So you should be knowing what all functions are used, what is the purpose of those functions? So it will make you understand in a manner. So let's begin. Here for us, you will be discussing the Arab discovered it in the topic word of course, topic which we will be discussing in Berlin Waterman setup. So prior to writing the code and executing the solver window socket programming, these are the little steps. So before writing the code for your socket, said look line, this is the generic method building ordinal setup required for wood's seven flight. So first of all, since we will be writing the program and executing on IDE, that discord block. So far is we have to create a project, but a chord block. So this case on the Windows operating system, we have to do the sector in this manner. We have to add that. We have to link to them in good socket library so that we can use the functions or methods which are present in this Mendoza conflict library. Since these, these will be using when socket 32 library functions. So before I start writing the program, which will be calling the methods as are the functions which are defined. In the library that, that is called as w that we have pulling this library, if you don't link this library, once you compile the code, it will compile because it will get there thereby. But, and you execute the code because you know that while executing the code, it will be linking to that. I really fine. So in that case, it will be finally the library. And since you have not linked to the library in the modern sector, then you will be linking letters. So don't worry about this. We will also see how it will only be in the next session when we start, I think the program, so this is for your understanding purpose. I have also mentioned in the presentation itself that what all things are done step-by-step so that you can live there and repurpose some video. And we can refer this presentation here itself. So first of all, we have to create an empty project and not woodblock. Then, since it'll be writing the program for the C plus plus, then we will be adding an MPC plus the source file to the project. So I will also show you in the next session and we write the program in the pore block itself. How to do just these are the steps which are made me no, no down off it. And we have to ensure built in water and then links to them and Socket Library, that is Ws to underscore particularly short-lived. So these are the steps for linking that also I have mentioned here. So we have to go to the project, we have to go to the middle option and then click on the link percentage settings so that our linkers link goes, I think, so that you can link any library to it and add the following and the linker options. So all these are the steps to add Susan's me or using really be using writing the program for the socket for the Windows operating system for cell hook line. Since we'll be using the methods as well as fungi are the functions which are defined in this library file, that is, this one, Ws to 32 dot. This library contains all the windows object method's functions defined. So therefore we have to link in this manner. You will be linking, might be giving these two lines that is minus W in particular and this one. So this is very much important, will be also seeing in the next session how to achieve, how to perform this step-by-step losses in order to link these libraries. Since this library itself will contain all the methods or functions which will be using for performing them in those socket programming. So this is debate of Northern men don't set up which is required for writing client program on the Windows operating system. Then I have mentioned very much important if you don't use libraries and you really get to avoid that. You have to do this billion more than one set of letters in killing that library file. Then you can begin the programming for the mini socket application for Windows operating system by this mentioning header file. So you have to mention them in socket DO2 header file that also explain you in the next session what all enterprise Arctic wire you have to manage. You'd have to include actually so that you can know golden functions. And when those socket. So these, so via, via the identity disbanding Waterman density for Windows for socket server programming. Now let see other topic of this session. So here we're going to be discussing the common methods which can be used for both socket settlement as well as client following those. So this is specific for a specific part of Windows operating system. This particular function is used that is common for server as well as client, that is Ws tech startup. And it is having two arguments. So you can see this forced argument as given in this man. And the second, I'm human doesn't address on this WSDL leaders. Foster boyd, What is the purpose of this WSS startup function? And it is required we have to, you have to use this function in Bork said, Venice client, supposed to boil by what is the purpose of this OWN a start-up. It is used to initialize the library. So since we have seen that the mental KC library that is sneaking in Berlin Waterman setup. So to initialize the library, this function is used. So what this function will do, west appointed to posts, argument register, present sensitive, and initialize them in soc library. So the cost of the program will really help us all Lindbergh wrote down one to use, which was this hybrid even socket that may be mentioned by this post arguments. So this make work and this band is, as you can see, Denon record two comma 0 specifies that the program wanted to use a version 2. Although library there is we have seen, so if we have given different version actually, so this going to defining their devotion actually budgeted program one do you like only so I have mentioned here itself the FED ME DO, which was of Vin socket, the program one. Oops. So here the main, what DO comma 0 means? It wanted to use the washroom 2.0. soda program when to use a version 2.0. or that mean Socket Library supposed to apply this function is used to initialize the library that has meant Socket Library. And the post argument will tell the program wants to use, which was one of them and socket. And what does this second argument telling about the forced upon this second argument which is that it is the address of WSB data. What does this WSB data structures? So 1D structure, like I had mentioned here. Suppose you put a second better meadow is appointing DO know WSSE data structure. So this structure in which the liability even tell the program built on negate the program about the critical information that the library, even Socket Library. There though. Program that how much number of sockets are required to be created. So that is a critical information which the library will pass through the program seeing what are, how many sockets, number of sockets you can create. So this structure will be filled actually before. So the structure will be quit before returning from this function. So I hope you understood the purpose. It is used to initialize them in soc libraries. So yeah, we have to mention the abortion which you want while they've been socket library. And this will provide, this will communicate the information, critical information from the library when socket library to the program, seeing how much number of sockets are required. So this is what the function is required and this is specified on need-to-know windows of what a Windows operating system on this function is required. You need to use this function for a board or server, as well as what lie in wait for the Linux operating system. I will be also mentioning what other things can be used for Windows and Linux so that you can start the programming with Linux also. So also a downpour you, since this session is explaining you about what all functions are present more and more admin setup is required to perform socket programming. Sort of alkaline water windows operating. Also. For the Linux operating system. Almost seem functions which you can use. You don't required Debian Linux operating system, the built environments, or WE simply you need to just install the compiler GCC and it might be already stored in your Linux operating system. You don't need to link these libraries. Also we have seen in Windows and the system that we need to link all of these libraries, Albia delink, only this library that is Louis Zoo, and an endless quarter D2 decidable socket library. Since we have to call the functions from this library. And so this function is defined. You should not get delinking Arezzo have to link this library, but in case of the Lena's Feistel foil and this library. So in case of d, industry dorm, wire dueling, this library that is no build environments set up like this. Nothing is required. Only you need to, you need to make sure that you are GCC compilers installed. That only is done for the windows. We have excluded this extra sector. We have to link this library in order to use this functions which are present in this library. So this is where the trends and Windows and Linux. So also in telling us we don't require this function, which is that this function is not present. So almost all the functions are similar to Linux and Windows are similar only the fuel methods which are not used in Linux and there are difference in only few methods. So a dysfunction, as I told you, is only specific for Windows operating system. This is not used for the Linux operating system. So a line by one, I will also differentiate within us so that you can start your program with Du Liniang soil so there is no much difference, unevenly or minimum difference is there. So that will be very much easy once you are capable of doing the program in this Windows operating system, it is very much as equal to win the Linux because wondering goes, these are the steps and board earliness. It is more easier than this. So you can understand, you will be invaluable for whom the programming. So we will also see in the next session. First of all, let me see the next session what role methods set up static wired one also the Linux operating system to go home the socket programming. So they did this session really tenable. What does metalloids and Berlin Waterman synaptic wife or Windows operating system. And in the next session I will discuss what methods and quarter million Waterman setup is required, what header file is required for the Linux? And then in the later session, consider differences between the socket programming for Windows and Linux waters have depth is required. What are linking libraries in windows we have to do and not we have to do for Linux and we're don't header files are required. And what difference is in methods or all the points you'll be discussing step-by-step. So let's see. So I hope see you understood, understood this focus on w And now to the next TO function, which is common to both server and client. It is socket function. So this socket function you have to create or sideways as well as wildlife. So we have seen in our earlier session on so that was our inclined board. Navier did require to create a socket actually, and it need mournful communicate between server and then the socket which we will be, we will be using, you'll be creating shouldn't have the same socket type as well as they should be having same ambulance domain. So these are basic things about the socket and discussed in earlier sessions. So I recommend that, I recommend you to go through this, screw through that session before coming to this. So it will also help you to understand what is, so what is the purpose of this socket? I stockholders soccer indices are published that is used to create a socket. So now while creating the socket, we have dimension. What is the socket type? So here you can see the second three arguments present. And that is if I underscored ins and song underscore cream and this is a group of oil. It is IP protocol and PCP. So hostile that ever via creating socket, we have to mention the socket. So this archetype can meet the streams type or it can be a panam page. So I will also mention on insertion basic socket that though, what types of sockets are available and Warhol address domino soul here, this socket types can meet unreliable type. That is the obvious team pay on unrealistic picograms of using the stream that is reliable. So most stronger tying this gene diapers news because it's very much reliable. And what all things were done. And as I mentioned in the previous session, please go to it. So this is the second argument topic. And lets see one by one or two or three arguments are. So, OK, so here this occupants is consisting of three arguments. The first argument EF underscored, that is the smart water this, so it is an Internet address family. So here we are using the IP version four. So there are two types. There is IP version four and IP version six. So since we are using IP version four, we have to write this internet address families ir, underscore RNA. If he would have use IP version six, nannies should meet IAA and the school and specific for that logistics via blue, right? So this is this metadata about the internet address families. So you have to give in this magnet itself. And the second argument that socket stream that as I mentioned you, that it is a streaming sockets. So this reliable socket. Then we have to mention the type of the socket, whether it is a big theme type on REP dissolve, datagram type, so sincere and using steam. So you have to mention you and Todd argument that is this one. It is, it is mentioning which protocol is used and for this orcas Gim me, have you have seen it used a communication protocol, RTCP. If this dipole, this socket was there, datagram, and this will be a UDP. But since we are using their type of socket, seems so it's communication protocol is TCP or oblique IP. So I mentioned in the earlier session or the socket V6. So please go through it for understanding what is illegal. So no editable redundant socket method will return though. Descrip goes or refresh referencing to the creator socket. So what this particular function admin ridden it Mildred ridden on descriptor to adopt new socket which is created. So by adding that descriptor which you'll be getting there. And you can use data descriptor and you can operate the perform different functions. So lets see one by one. Now, another common method which will be used for server as well as client is the clue socket. So here it is used by the name itself. You can understand any other set of a socket or it can decline since it is common for both seven and plenty of Lukoil dysfunction. So here we are calling for those service idea of looking at this, I was occupied. That is a descriptor. Any produce deadlines, soccer, then you have to give their descriptor of the socket. So year two for this, it is used to disconnect this rocket, and this is v. For the Windows Operating System, we have Golden Globe socket first of all, and then you have to do w. So what does this WSS cleanup? Because to deallocate the resources which are used by the Socket Library. So this soil are the details and how do you use it in this manner? So these are older, are the common methods that will be useful. Sidebar as client knowledge see specific methods which can be there while the server. And then we will be seeing the specific methods for the lines bothering those operating a system. So now our friends are going to be, now the specific methods which we'll be talking will be common to board or the Windows operating system, as well as whether the nurse operating system on these specific methods are seem. Though that is no difference in the functions for Windows operating system as men as one Linux operating system and you write socket program for sovereign claim. These are the common methods. It can be used what will adopt them. So only the difference I told you was in this function that is WAC started setup is used on Ebola and goes operating system. You have to require a, it's common for server and client Windows operating system, socket programming. And also one more thing. And I go disclose socket. So this is also one difference and windows operating system and solid. In case of Nino, so-and-so you will go out glucagon that loss. You will also disconnect the socket, but not calling this function will be on IQ loss functions are to be met and be mentioning that in the next session, what methods is used? So only that Louis XVI use, you don't need to clean up all the different ways there to closing that to disconnect the socket. So this is only the difference in between the windows operating system and done Linux operating system or socket that look lines. So all the resting stack now we will be discussing here, that'll be Coleman, Do the Windows operating system, Linux operating system.
8. Socket Session5 ServerClientMethodsLinux: Hi, welcome to this new session, that is sockets advert
client methods. Minutes prior to the session, he had seen the lecture for socket server client
methods for Windows. I hope so you've
gone through it. So it will be good enough
if you've walked through that session because almost same concepts
is explained here. But I have a differentiated
for the Linux. What specific things
I used for the Linux, what all complete setup is required you'll be
discussing in this session. It is not more than that. It's not much difference. In the Linux and
Windows socket server that only few method
defenses rest all are, them are same as come back
to the back of them windows. So I hope you've gone
through the earlier session. So to understand more quickly on this session, I'll cover it. Little colliculi because
almost the common things which are here present, Linux and Windows mu will be moving weekly and rest of the things which are
specific for orderliness, I will give him on that. So that is going to be on
so far you to sink more easily instead of going through
what session repeatedly. So let's see here, what is the sockets have
online methods for the Linux? What all things are,
they're not required. Let's see, step-by-step. Don't worry, you will
understand each and everything. We will be moving step-by-step. The topics which I'll
be covering here, it will be discussing
the common methods are the APIs which I didn't record board server
as well as clients. So these are the two methods. So here in the first topic
we will be seeing what all common methods of
functions are there, which for the
sidebar then client, and that is used for the Linux. So these are the methods
which are common. That is, there are two methods. Socket method is dead and the another method
is the close method. So in case of Windows,
we have seen, in that case one extra method was there that is WSS startup, I told you that is used
to initialize them in socket library and we have
to link onto that library. But in case of Linux, that method is not
at all present. That was an extra thing
regarding the windows. But in A's ugliness
that is not there. So we'd also need to link
any library, meant socket. We do need to link any library
in case of the linear, it's just you have to install. Gcc compiler is installed, and we are able to
start the programming. These are the methods which are common for
server and client. That is, both of
them will be used now let's see what it is. Now also the other topics which will be discussed
will be the side where specific methods and we will be sinking
with the courts. And we see all the methods, whether side-by-side, which is specific to the server itself. And we'll be seeing all the methods for the client which is specific to the client itself. So also these to all the methods which
we'll be discussing, model and specific and
the client specific. The same methods
which are used for Windows also all
these methods are used also for moving those. So almost everything is
same, just the differences. That year the WSS Startup
function is not using Linux, as well as the SOC close method
which will be seen here. The syntax operate is different. Everything is similar to that of the windows as well
as for the linen. So this function specific to
the server will be also same for the Windows and Linux and deadlines specific
methods will be same. So let us see the
things then discussing the same common
methods here govern methods used for server
as well as claim, this is very much required. The important node which I told you that in Lena's there is no WSS star dot function used that has window
have this function. You have seen that
the common methods which we have discussed
in earlier session, we have seen that there are
three methods out of it. One knows WSS startup
that was used to initialize the library, that is the wind socket library,
and you have to link it. So here in this Linux, this function is
not at all present, so do you don't need to
worry about linking also, there is no set up
required for that. So that only her maiden
who download it. Then coming to the
genomic methods which are used for server as well as client in case of Linux. So socket is used. So this is the same way you
are doing for Windows also, you have to create the socket. You have to pass
arguments in it. This first argument is
the address family. Here. It can be for IPv4, IPV6 when we give EF and the school I in
it, that means it is fun. I think he would
have mentioned six, then it knows what IPV6, this is this indented
and his family give as it is, as
I have given here. Second argument, you have to
pass the type of the socket. So this I had discussed in those topic Basics lecture prior to this session and said that though there are
two types of ducts, socket types, that
is stream socket and datagram sockets and stream
is a reliable one manifesto. I'm datagram is not
reliable and he had seen what all
features are there for the reliable one
and what unreliable, we're mostly using
their level socket most of their time because it provides error
correction everything. So all the things
that you can go to the first session,
so it could be six. And the third thing
you have to mention the communication protocol. So here since this gene, so I'll confuse this
communication protocol is TCP, we're mentioning here PCP, if it was though datagram and it uses different
communication protocol, it is new that also
I have discussed in the onions session on the
no damage I just mentioned. Then there are three functions the same way which I
mentioned for the windows also the same or
ignore it goes then this particular
socket method will return a descriptor
pseudo socket. Wherever you are creating the socket for the course
or where our product line, it will return a descriptor
to the socket for that dark line depending
upon where you're using it. Then the next thing is
that loads function. So here again, this
close function is we are using in case
of windows closed socket. So there is different
representation. You disconnecting the socket
as compared to the leader. So Nina's me, I use includes and we're maintaining
their descriptor. You if it is sidebars soccer, react losing it,
then you have to mention that it's
scripted of service. Okay? Yeah, I mentioned enclosing the socket product line than you are to
descriptor of decline. Then the next thing now you'll be seeing those
hardware specific methods. This is common for
Linux and for Windows. So all these things that will
be repetitive if prior to this session you
have gone through this session, that
is socket said, Well client quad windows,
if you have gone, then you will find this
thing almost same. This will be specific
to the sidebar. So we have already seen that the sidebar need to bind to
particular IP address as well as though port number associated whenever any communication
needs to be happening. First of all, we have
to show that server is running post so
that it can exist. It's capable of receiving any
connections from the client whenever that is an
Ignite this client, how it will understand the
identity of the server. So that is the reason
the Salvo should be binding to a particular IP
address and port number. By the name itself you can understand mine means
it is binding to something inside
of whether it is binding to the particular
IP address and port number. So this whole, what I
have told you is written, this is how you call
the bind function. You write the pulse
argument as a descriptor. Then you re the second
is a pointer to the structure and then the
size of the structure. So this descriptor is
a descriptive which you reach the socket when
you call the socket method, it returns the descriptor to the sidebar socket so that
you have dimension here since via a sends me out
using their descriptor of that socket only we need to bind sediments, okay,
We need to mine. And the second we are giving
the structure of the socket. So weiter structure is required. It is required so that you can fill the details of
the address where this advice should
buy into end up with a number and other things
like address family. I also explain you this address
we're filling it is if we have given in server an EdD at underscored and
install a new session. I'll explain you want to sort importance of it is
very much important. The code number, it
should be greater than 10 to four because it is
used when 0 to four. So it should be
greater than 0 for any of them used in
particular number. It is explained by three-fifths. We'll just go
through and see what is the limitation
of it is 65535. And then this is the number
one, whatever you mentioned, the port number on the
server you have to mean mentioned the same
window. Client outsource. This is a port number on
which the server is buying. Do. I have explained now when we have done
error checking here, you can report it later. So I have explained you
all these parameters. This is just a No, don't put it. Seeing the next function are decided by that is
listened function. This is common to both
Windows and Linux, specific to that server. Socket. Socket. For the lesson, once it binds to IP address
and port number, it should listen on that. To listen Dan, new
connection from the client. Also, one thing I have
added here just now because it's some type
of mistake was dead. Also, the same thing actually
just listen function. I have missed that in
case of the windows also what the server
socket methods. So here the extra
parameters that, that is in bendy are
called Allison punch. But in the programming I have written in the same
manner we have done, which I'll explain you,
which will be executing it. I've executed in this manner. It said, passing the two are
humans that is required. So just mentioning in this
presentation, I missed it. We talk about the lesson
function when extra pedometer, which I have edited
as the backbone. This backlog of which is
the second argument here. What it is, why it is
required most of all u and v mentioning the
sidewalk socket descriptor. In the second backlog
means it says how much connection request of the client should
be in the queue. For example, if you give here. So that means you
are saying post-talk on this socket is capable of receiving either board and actions of economic decline. But that will be in the queue because since the Bazin
One is in the process, if there are multiple lines, then magnet and actions will be in bending connection request. So those will be waiting
actually for an oppressed in one who complete runs the
present mine is completed, then the side value
will be listening to those of the connections
one-by-one at a time. One will be processed, but other will be in the ICU. So how many number of connection of the client
you want to keep in Q, you can mention in
this second argument. So this is all sources
seem in case of the Windows operating system. So I have explained
the lesson function, but I have missed giving
the second argument and that just consider the same
thing that's in Texas, same since I just see him
for Windows and Linux. So the second argument will be added rest,
everything is saved. Just I missed this one. Now, this is how you will be listening for other new
connection requests, for their connection
requests from deadline depo dysfunction. Then you are calling
the exit function. And that's I wrote
the exit function wherein you will give the
descriptor here on the server. And then you will mention the
pointer to the structure. And then a year during different
things which are there, that is client a DDL,
which you will get. So here, first of all, in case of the exit function, this structure which you will be giving us all what it will
return this exit function, it will return our descriptor
of the new socket. So all you got to socket descriptor post
socket descriptor. You glide menu called
the socket function. Here. When you follow the
socket function, you bought one descriptor.
So there it is. It is used to receive
any new connections. For the connection
purpose it is used, that is this sort
descriptor which you get actually when you call the exit function
and this address. This is Doug descriptor powder. It is named as glenoid
socket because you'll get a descriptor for the new
socket descriptor or decline. So here with this script, you can communicate with
that line as well as you can send the data to decline or do you can receive
the data from nine. So deco photographers
could have Bazaar used as do not
block anything once that socket descriptor
can be used for connecting the
client requests and ISACA descriptives get engaging in sending and
receiving the data. So there are two descriptors. And this is how destructive the judgment explain you what, how to fill this structure, this structure you have to do. You have to mention the details
of the structure itself. The next thing between
seeing is that a C function. So also one thing while the server socket you can
call the receive function. You can call the same function. So anything you can call
depending upon the requirement. I have a nice look
into this index. But this isn't used to
receive the message from the client to see if they're
the adapter on that line. And here you have to mention
though socket actually. So here since we cannot
create the socket, actually we got this
descriptor when we call it, exhibits are at the
descriptor itself. We need to receive that. Whatever we receive from client will be collected
here before you can print this before it
is industry in character. So this is what the in case of the set of functions which
are specific to server. And these are the same for them in those and as well
as for the Linux. Now let's see the client methods which are a specific deadline. So reclining to just connect it same manner which I've explained you in the earlier
session for Windows. It is used to communicate
on the network. It is must do connect
to the server. Here we have to mention
this address structure. Also one thing I'm going very
fast in this session that is for the socket sidebar
client methods for the Linux, because in the previous
session that was sockets advert client methods
for the Windows. I've explained you everything
for the Linux also, the same thing just, there is a beauty Prince
which I mentioned you and your itself
rest dysfunctions, which I'm talking about. Almost everything is same. So there is a reason I'm just going really passwords very, it's recommended
that you bought with Danio session to
understand it more better. But I'm covering
each and everything. I'm not missing anything. So I don't want you
to go repeatedly. That is a reason gambling
past here to connect. **** line is only
supposed to connect. So this is the thing we
inclined to give their debt. So this is dimension though, IP address of the
local host machine. So in our case, E and B having the socket communication
within the same host machine. So it's even if you can, you can have socket
communication within the same host machine or
within different machines. So in that case, whenever you are having
a socket communication, you once I read inclined to
run in the same machine, same laptop seemed like stop. Then in that case the IPS, it should client
should connect to the salvage of give the IP address on the server where this ivories by m2 so that you can
simply mention the idea of the local IP address
because since we are running server client
on the same host machine. So in this manner, you have to, you have to mention here the
IBM Internet and his family. And the port number you
have to mention me was we had binds to
this port number, so I'll give the same on
the client side also, since client will be connecting
to the same port number, then we call the
connect function in pasta's descriptor of the socket which we got by creating it. Then this is just structured
between repealing with this, I'd be at this end, port number and the size of the structure. This is the, this is an old
Donato about table are the, another function is sensor ones. It's the client, that's
the connection by simply calling the connect
function in this manner, it is simply then it can
send and receive the data. So this is a syntax was
and you can also receive their quality seed
function from here. Sending it, we are sending
some character string, same thing, learning socket
programming in depth. We're passing the
socket descriptor data, sending this character
string which we have failed with data Buddha side of it. And then also from the client, that is from here itself, this data will be sent to the server in the
size of this thing. So this is what we
will be sending compliant to several friends. I am done with this said
Brookline methods for Linux. So you can understand
to summarize in short, you understood what
all the princes, their poster for a
dipole in Linux, there is no setup or linking the wind socket
library since we're not using those functions. In case of Nina's there is
no WSS Startup function. Therefore, this thing
is not dysfunction is not president case of Linux. Then rest other things like socket creation is similar
to that of the windows also. And the closing of the socket, we have to disconnect in
the case of Windows also, what does index foreclosing is determined in
case of Windows we call glue socket and
there are different, we do the cleanup also. But in case of the Linux, simply recall that
Lewis function to disconnect the socket. Then these are the
specific methods which are used for the server. Those methods that
are binding or the sidewalk that we
will be listening then accepting all those
things which are that will be common for Windows operating system as
well as for the linears, for the Lynas who answered the same and for the
windows on the scene. These are the things
which are there. In case of the client-side, also the client's specific
methods which will be there, that will be also common for Linux as well as
whatever window. So you have to connect
from the client. We have to send and
receive their function. Send and receive the data. So this is what we have gone through now in this
session I'm going to explain you the difference
between sockets set of applying for
Linux and Windows. So that I will explain you. This is all many things,
so they'll be there, which will be common
till now we have studied that is the winning
Waterman set up on Windows, just mentioning it to
link the library and then inconsiderate Linux
to just install GCC seemed to make
sure this is evoking. Then I'll explain you
what all header files are required for Windows, what own header files are
required for the Linux? Then what extra code is required for Windows and what
common methods are there? What I type checking, how you will report
an error in Windows, how you report in Linux. Dead lecture. We will be seen once you go
through this session, then later on we will be
starting the programming. Those middle we've
seen you'll be learning it and
also in wheezing. One important thing that is HTTP server client communication will be running if
you didn't see, seeing how the browser
talks with Apache server, how the communication
takes place whenever you open any site, whenever you want to open any Beijing Jenny on the browsers browser
is sending a request, how it will be connected
to Apache server, and how the data will be filled, how the page will be filled
with that, with that data, the page will be
loaded so that we will be seen using the socket, be using the HTTP
server communication that is very much important. So this is how we will be
proceeding step-by-step. Thank you. Thanks a lot.
9. Socket Session6 Difference ServerClientMethods ForWindows Linux: Welcome to this new
session that is difference between Windows and the
Nina's socket programming. We have already seen in
the previous session the windows socket methods as well as billionaire
socket methods. And I hope so you have gone
through those sessions. They will be very much helpful to under
spirit this session. That will be this
will be giving you the difference between the
windows as well as Nina's. But some adults here. Let's begin. Topics. We'll be covering the
defense in building water Admin setup to perform the socket programming
in Windows and Linux, we will be discussing about it. The next thing we
will be discussing what all header
files are required for socket programming in Windows and as well
as for the Linux. These are, these header files will be different
for both of them. Then we will be seeing the
defense and few methods. That is a functions for the socket programming
in Windows and Linux. Bob. So in this third one, you might be a metal almost everything because we have seen in the
previous session itself by making you understand socket programming for
Windows as well as Linux. I had told you what functions are used in Linux and Windows. Almost seminars are almost
all methods I use red cell, onsite depo windows and some slight difference in one of the function
and the rest. All of the things I've seen decided the setup. So let's see. The fourth, I will be
discussing the topic that is different scenario
Reporting between the windows as well as Linux. So let's start now the first very posting
that is the setup, the prince and the bill setup
or both of them, false. We will be seeing
the bin setup for the windows to perform the socket programming.
So this is B. This will be kind of
repetitive because we have seen in earlier
session on source, the Windows operating system to perform socket programming, we need to link to
the library that is ws underscore 32 dot lib. Because we'll be
using the functions. Functions are defined in these libraries for the
window, window socket. And therefore we have to link this library because
execution time, if you don't link this
library later on when we execute the program, then it will give us
the linking later. It will not find the library
since we have not linked it. So this is very much important
and the steps to link it, I have mentioned here the same thing, project build options. Then we have to click on the link or setting
tabs and these things, these are the steps that
you have to navigate. And then you have to
add these libraries. We will also be writing the programmer and show you
manually also how to do it, go through it on the
idea and explain you. This is very much important. The setup is really important. Otherwise you'll get a
linking at execution time. Now you have dimension, the header pilot case on the
window socket programming. Now, these are the
building Waterman setup, the elementary unit
if I later on. Then next, the building
Waterman setup for the Linuxes, you need to just simply ensure that your GCC compiler
is installed or not because it is
news to compile the code that are
different though ideal. And so if you want to go
through UI user interface, you can not do the command line. You can install particular ID, that case, and you can
create a project actually. And you can send leak or programming code and random or random socket
programming code. You don't need to
link the library. If you are using a
command line drawing, make sure that your GCC is, this is a compiler
is installed or not. It will be by default installed
on images and shorter. No linking libraries
will be required in case of the Linux ones. And we have to mention
some header files for the Linux also to do the socket
programming that we will discuss later in later slides. Now this is, this whole setup is enough to start the
programming in Linux. So this is what
evidence actually in Windows and the liberals. And the next difference
for the header pricing between what the
header file should be included or Windows to perform the socket programming
and for the linear zone. So this is in files which
you need to include my Windows operating
system to perform the socket programming.
You need to. I mentioned this stdio.h iodo, THE simply input-output to simply display the message
on the console or to simply give the input
from the console. This is what though. These are the credit
files which you need to give in case of Windows. Then the wind sock dot edge, this is specific to them when socket functions which will be declared in this header file. So you have to mention
this header pipe. Then you have to mention
STD lived on the edge. These are the three header
files which you need to give performing socket
programming in riddles. Then deadliness, you have to mention all
these header files. That is stdio.h
DIN socket dotage, I dotage, std lib,
string dot edge. And then you Anna,
Anna, UNI stdio.h. So all these header files. So you have to give, in case of the Linux operating system and you are performing the
socket programming. These are the differences
between them. The next topic actually
which we'll be discussing, what all different methods are there between the
different for Windows and orderliness when we saw a white socket
programming so far, windows, as I told you, this is the extra
function which we use. This is very much required for the Windows
operating system. It is used to initialize. You all have been socket
library though it will tell the network the program want you digital version of the library the program
wants you to use. So this will give
you the version two dogs 0 on the
wind socket library. It will, the program
will indicate this version you need to use
for this Mintaka library. And this function is used to
initialize socket library. And the second data structure
pointed to the structure. So the structure would have been socket library will provide the communication
critical information while communicating the program, seeing about how much number of sockets and allow
it to be created. So all these things out
there in case of New, in case of Windows operating
system, not in Linux. So this is an extra
function which is that in the Windows
and you don't know, you don't need to use a nominal. So this is a difference
in one of the function. This method dispatch
them individually, IX being new version, the course better read that as the visualization on libraries. Second, when I give you
the critical information how much on this
sockets can be created, there'll be sent from the
library to the program. This I had mentioned.
Yeah. Then Nina says I told you there is
no stock or function, no initialization
or cousin Nina. Now, another thing is that
in case of the windows, these are functions which are used to disconnect
the socket. We have to call it
close socket function. You have to cause this
socket descriptor. That is what I was
hoping that because I said about our
client had two fathers scripted offer depending
upon your requirement and WAS a cleanup function should also be called in
case of Windows. So what is this WSCC cleanup? It is used to deallocate data sources that is
used by the Beanstalk. This is definitely in
and it will return 0 and success and non-zero
number on failure. So I hope you understood this. These are the, these are
the methods which are used in case of Windows to
disconnect that socket, no functions you need to call. And there's a purpose
I've explained you up for the WAC cleaner. Then in case of Linux, in order to
disconnect the socket simply you have to
call the close. Then you have to pass
this descriptive. If it is satisfied, then
it will be the script up. If it is a Linux, if it is client, then it
will be applying. Good to go. This is simply closed. There is no cleanup and all. Then another difference and other topic actually
further defenses, defense and edit reporting
between Windows and Linux. So let's see for Windows, how do they vote in error? This is the function
edit response. The message will
be getting here. Then you would simply put this message and this message
and get it collected here. And this is a
function that is WL, I say get lost error. In this manner, you have
to report an error. So what does this
WSL getClass error? Now let's see details about all these things
now in window uses its own error message
facility yes to indicate that what went wrong
with the socket call, this function may return an integer representing
the last area there have a good decade by the socket
call field disability. Give you what my, what is the reason
of the socket video? It will return an integer. Now this has Windows version
ICD-10 of the edit responses uses duck, the last error. So this is all the
description about it. In case of Windows, we need to report an
error in this manner. Now let's see for the
linear Sweeney nuts are getting the same function, but this time that
it didn't call, we will do even call. This WAS a getClass
and of equal sum. If didn't function, that is B editor and
the editor message Yoda was SP edit to report
the system error messages. This is a difference. Now, all these things
are required actually. So this is, these
are the differences between Windows and Linux
socket programming. So you can see not much
differences dead or functions. If you talk in terms of the
functions only in Windows, you have to add an extra function,
OWASA Startup function. And also one other thing regarding the function is that the loss function is different. Syntaxes, different
model, Windows and Linux rest all
the things that is specific to the server
in specific deadline the functions are same so we don't we have
not talked them. I'm just dabbing setup is
different in case of Megiddo. So you have to add
these libraries, as I mentioned in
this step here. In case of Linux, linking
setup is required. And on Nipah Linux, we have to make two other
if your compiler is installed and the edit, the header files
which I mentioned, these are the
different enterprise for Windows and for orderliness. And the last thing about
the rape error reporting, this is the different discourse, different function in Windows. And in case of the Linux, it will call the different
function that is better. This is what, this is all. You have to keep into account. Both bombing the
socket programming for Windows and Linux. So don't worry, friends
now in the next session, even be seen socket sideward
client communication. It will be writing the
set of vertical board for the Windows
socket programming. And we'll be writing the client
code for the programming. For the client code for
the windows will be and then we'll be doing
the communication. I will tell you again, understand that there is many minimum difference
between Windows and Linux. So once you know the coding of the window for the socket
programming while you are, it is just one big
go actually, dude, to write a program
for orderliness, you don't need to
worry actually, it is just to copy paste actually gets off Nina's
because in Linux, it is very much a z than that of the windows are because some of the functions are not used. Also rest just the
defenses in there. The close function you have
to call indifferent minute as everything is same and there is no set up required
for the Linux. If you know the programming for socket programming or
decided what as well as client for Windows you
will be if it'd be very much Z redo the socket
programming for Linux. So this is how we will
be proceeding trends. Thank you. Thanks a lot.
10. Socket Session7 ProgramExecution ServerClientCommunication Windows C++ Part1: Hi, welcome to this new
session that is said about applying socket programming for Windows in code block
with its execution. So here we will be writing the code for the server socket programming
we will be doing, will be doing the client
socket programming, will be running it
for the windows, will be executing it
on the code block. And we will be seeing how would this socket set of applying
a minutes with each other. This session? I hope so You have
already visited the, all the previous session
in segments rice because we have covered
the different methods, different functions, the socket server
as well as swaddle, socket client or Windows, as well as we have also
sync with the code. What instructions are used, what all different
functions or use, what is its purpose? And how to for the server side, what all functions as opposed to be colon for client side, what functions need to be? Saw? All those things we have seen, we have also seen the
building water admin setup, which is required for Windows socket programming
to take place. If not, then please
visit those sessions. We will be starting coding for the sidewalk line
socket programming. It will be very much physical. You still, I will be
explaining since we'll be creating a new project in order to write the code
for the server, the client socket
programming for Windows. And we'll be doing the whole
complete the list myset up, seeing what all things
we have to link. What are libraries
are required to link? So you will still be getting bands we go through
this session. Let's start. So to just revise, we have seen several
socket methods. What are the servers are
good methods we have seen. First of all, there is, you have to initialize WAC. This is required on
Windows for Linux, we don't need to initialize WSL. So we have seen what is
the purpose or topic. It is used to initialize
them and Socket Library. And we have seen how the
program will get the abortion. It one, but I've
been socket library. So the posts are human. We have seen, you have seen
what is the second argument. Ended up APA Socrates to initialize dove and
Socket Library. Then second function we have
seen to create a socket, then it will return or
descriptor of the socket. So we have seen that
at creating a socket, we have to give the
socket type and it is regulated as
a stream socket. It is reliable
socket or whether it is datagram socket at
some level, socket. And it's about as
we have to give the communication protocol. Since we know that stream
socket is using TCP, datagram is using UDP. We can create this socket AND gates on the server methods we have C and then we get
this socket descriptor. Then on the server
side we need to bind this socket to diabetes and
port number we have seen. Then we have listened
on that socket. So we have seen no van, we listen on that socket. We will be passing the
socket descriptor, as well as you'd be mentioning
in the second argument, how many number of those
socket connection from the client should be in the pending queue, in
the waiting queue. And then we have a
boulder exit function to accept the connection
from the client. And then once the
connection is established, so when we call this
exit manage function, it will return another
new file descriptor. And this file descriptor, we can perform send and receive began for home send and
receive data with that client. This socket descriptor,
which it was. So return from this
create function. This, we will keep it engaging
to accept the connection. And another socket, new
socket descriptor W, keep it for reading and
writing for communication with that popped up 9% data as
well as to receive the data. So this is how ended disconnect
function we have seen to disconnect the socket in case of the server socket methods. Then we have seen the next thing that is the
client socket methods. I didn't need to
initialize the essay. This is also specific
for Windows only. Initialize the
wind sock library. Then we're created the
socket on the clients I underlined there is no much code if you functions are used. So we have to
initialize the US it to initialize the wind sock
libraries so that we can use it. Then we have to
create the socket for that client and server are
different applications, each of them to have this
socket creation on them. And also we have to mention
the same socket type as well as the target
communication protocol should be same either side, but as well as
sparklines so that they can communicate
with each other. Then we will call
the connect function so that the client can send a connection
request to the server. And then once the connection, once this connection is
accepted from the server, then send and receive stats
from the client itself. Then disconnect function,
don't disconnect the socket. So all these methods
we have seen now starting now let's walk
through the server, client server programming
in code block of Windows. Let's create a new project that you need to install
the woodblock IDE. And it is really availabilities
and open source. So you don't need
to buy a license. If you've seen, if
you install this ID, you can write the
program with me and executed and see how the
communication takes place. I've already installed it. I'll open the whole block ID. I'll create a new project. So first we will be creating a new project
for the silver. Then we'll create a new
project for that line. Once the code block
is installed, just double-click on it. You will see this page. Now, let's create a new
project by clicking on File. Select new, and then
select project, and then select and
soil application. Then click on Next. Then since we are
writing the program in C plus plus it's already selected, click on Next and then
write the project name. So this is sort of a socket. Windows should be
very sensible name as well as short name so that you can understand what you
are doing in the program. This is a folder name that you
want to dump this project. Then click on Next and just create a default Hello
World program for you yet. Now we have to replace
it with the server code. I've already written the code. I'll copy here. I
don't want to waste time and writing single,
single instructions. You have already seen in an earlier session what all
instructions will be using. I will also explain
you line-by-line the instructions on
game program itself. And then we will
be executing it. While you do it. Again. Writing the whole code, let's dump the code which
I've already written. The code which I've already
written I've just downloaded. I have just increases, increase that
exercise so that you can see what coding
we are doing. To increase that excites. Now let's start by understanding
this program one-by-one, line-by-line on the server. So it is using the same malfunctions which we have already seen till now. Now, the execution of your program starts
from the very first, that is the main function. I hope so you might be knowing
what is the main function. Main function is the function better it whenever
you compile the code, whenever you execute it, the execution of your program will always start from
this main function. Whatever lines of code you will be giving in
this main function, nine by nine executed. And it is an entry point
to start an execution of the program so that control costs comes in this
main function and motor, whatever lines you
have written here that will be executed
line-by-line. Now, let us see for the
server code what we have written for
socket programming. We have declared, we have
seen this as WIC data. We have seen what it is. We have, we have initialized, we have created, created the
variable on this data type, that is WSL data. We have seen that in case on
the windows, you have foo. Initialize the wind
sock library for that, we will be using. You'll be calling
startup function. This startup function is having two arguments
out of which the second argument is the pointer to the
structure WSL data. So widest structured
as required. We have seen that
we need that DO. Those are library events often. It will communicate
with the program, giving dog information
about critical information, that is, how much number
of sockets can be created. This structure will be filled. And so since we will be
using it, therefore, we have to create a variable offered in this
manner, WAC data. Then we are creating the
object of this socket. We are having two
objects on this socket. We know that the socket descriptor will be receiving when we call the
socket function here. And I've got a socket
descriptor me to be deceiving when we call
the except function. So exit function onto their than one mode socket descriptor. We have seen that
there is a reason yet. Creating the object
of this socket, we are creating new objects by the name server socket
and by the name I'm sock. Then the next part is SOP
ADD or underscore ions. So we are painting
again to object because in V&V called
a socket function. When we will call
the bind function, you have fulfilled
all structured with IP address where those server will be hustling and
with the port number. So that is the reason this
structure will be required. And that will be at
creating the object of it. And then again, my most
structured is required. It is required whenever you
call the exit function. Here we have to mention this. It seems here. That is the reason this
is required and you are creating on deck
offered in this manner. Now, the very first function
that will be called UFC, he have to initialize
them in salt library. So therefore we will be calling this WSS Startup function. And you'll be passing
two arguments. The first argument,
which will be better, it will tell the
program wants to use the version of bug
and socket libraries. So since the program
wants to use a version 2 before the first argument
is given in this manner, make what in bracket
two comma 0, that means the
program one to use. When Socket Library 2. The second one that is a
pointer to this structure, this structure of witches, that the data will
be here though. Socket library
with elder program or how many number of
sockets it can be created. So this will get filled before the WSIS Startup function
comes to an end. This is how this will be passed as an EMT
and it will get filled. Haven't talked library and this information will be filled. How many number of
sockets will be, again, be created? Exit
prior information. This is how we are calling this function for the window socket
programming and server site. Then the next thing,
since I don't, you know, part of the rule
is to create a socket. Now we'll create a socket. So by creating the socket, we have to mention we have
the victory things that is posting will be
the address family. So we will be using IPV4 and deployability
in this manner. Second one minus the
socket, socket tight. So we want this stream
socket to be created that is reliable and carbon beta
communication protocols. So we are giving it as zeros, so did before it can be 0. For this stream it uses
TCP, you can use Xero. Another. Once we call the
socket function, it will return the
descriptor of the socket. Now, this descriptor
will be using for different functions ahead. That is for the bind function or the listener function as well
as for the exit function. Now, you can see what
we're doing here. We are filling this structure. So what is this set of ADD? I said earlier it is of
the type socket ADD. As we have seen that when
we call this is required, this whole code is required
in the bind function. Since in bind function, we will move on the
socket to be binding. Particular port number
and IP address. Port number and IP
address should be given in the structure. That structure is server
ADD or that is other types, sock ADD or underscore iron
via filling one-by-one. I told you this address, which we are giving for a
server to listen to bind to this address is what I have explained you in detail
in earlier session. Let me give IN, ADD
and underscore. It means that you want sidebar to all the IP
addresses for victim, different network
interfaces on it. Though users using land
to fetch the Internet, then the IP address of that land will decide where it can bind. And if the user is using Wi-Fi, that is different
network interfaces are having different
IP address dense over that IP address on
the same host machine. Then the second argument we're
mentioning the VM image. I mentioned the family. So when you give
them this manifold, IPV4, it will be in this manner. Then we are giving the port number quantity to the salvage of give me four times five. We can give any port
number greater than 1024, less than six by 535, because one till
1024 it is used. And though after 10 go for, you can give any of
the port number. So whatever port number you will always remember
the client side. You have to give the same
port number because clients will connect to the
same port number where the sidebar is mine
to all the structure. Once it is filled, then you will call the bind
function again. You will pass the
first argument as the SOC is what it is a
descriptor actually which you, which is which it was written when you call
the socket function. This is a socket descriptor. Here we are passing the posts
and human second argument is the structure that you may have felt
we're passing here. And then third one
is the size of this. Info. Now this, in this manner, by buying function
now the sidebar is binding to the port
number and IP address. Now what listeners doing
in case of the lesson, the lesson function, you are
passing the first argument as again the descriptor
of the socket. And the second argument, number, client connection, which
you want to keep in q, since we don't want if
you don't want any, any client connection
to keep in q, then we can simply
write 0 or we can write one if you want one connection, it will be in q auto
connection and cube. This is how it works. Then this lesson means
it is listening to, listening to the Connect
line connection. That's it. Then after that we
will be calling the exit function to exit the
connection from the plant. This mean bars,
again this socket descriptor that got returned
from the socket function. Second, we will pass
this struck dose, so destructed as an empty, it will get filled actually. Once we go on called
exit function. Here, all the client related
details will be filled out. All the information
related to that line. What is the IP
address, what is it, what port number it has mapped to and all
the details it will be filled actually when we call the exit function and
the size of this. So therefore we are
simply passing as it is. And then it is running, then you find new
socket descriptor. So this descriptor as
well as this descriptive, both of them are different. I told you yet is
different because this descriptor can be used to accept other connection
requests from that line. We don't want to get
anything blocked. So this Socrates engaged in, in listening and accepting
the connection. In that case. We also want simultaneously
read and write operation. Once it is, it is accepting one connection
from the client. We want read and write to be hunting and we don't
want it to be, but therefore, another load, the script of another socket or descriptive will be middle
GET and we'll keep that, engage in reading, writing
this one and this one. What accepting another
client connection. I hope you understood this and this and
this will get done. It once said about accepts that connection
from the client and it is capable to receive the
message from the client. So your descriptor itself, we'll mention here, if
this is successful, then only we can receive here. So therefore, if
condition is mentioned and this V right client
is going to get, you mentioned this
socket descriptive. Since we need to receive
on this socket itself, then whatever the client has said will be
collected on this buffer. And then we'll
display this message. Then memset is buffered to 0. And then this is how after everything is that
I'm losing the socket. So it depends upon your usage. You get on so-called
the same function here. If you want some
motor information to be passed from the server, then you can call
the same function. And if you want
repetitive connection, you can put up a loop here also. And you can write
the condition that if somebody walking
condition that it user give this and come out of the loop
and don't know Nieto beyond want any communication
depending upon the usage. Again, modify the program. This is a simple program and I'm receiving the message
from the plant decor. I'm calling this receive
function even I can call it a sine function if I
wanted to send any data. It is same. So safety
function and will be calling from that line so
clients can send a message. Even in the clients
that we call, we can call the
receive function, yet we will be here. I am showing you about receiving the message from
the client site. Client side will be
sending that message. Now, we are closing the
socket in this manner. This is how this happens. I hope you understood each and every line of code
and this will, we will find it more
than Z because we have done all the prerequisites before starting the program. We have seen all the
functions in detail. Sinking with the code. I request you to go
through it if you have not gone because I have repeated
all the things again here, but in more detail of
explaining that session itself didn't make
you to understand. Now, let's build up.
11. Socket Session7 ProgramExecution ServerClientCommunication Windows C++ Part2: Before that, you want
to set the lungs. So I've already said
the log to secondly, for increasing the size, I have just still. If you want to belong
here on the console, ward setting is required. Click on New, and then you
need to check on this locks. Once you check on this locks, then you will see this beloved screen I've already checked, so I'm getting this
will lock screen now I am how to build a
program. Click on. Let me clean it because I've already tried it just a second. Okay, now click on Build
and then compile that file. So here you can see there
are no arrows In TO, in the server side.
Now let us link. Now I wanted to show you
one important thing here. I have not done any setting probability
in water Admin setup, which I mentioned you
in the earlier session we're supposed to
do for the windows. I'm not done because I wanted
to show you the error. And then after the, you'll see there when we executed there'll
be a link in it. And of course you can see
I've not done any settings. I'm not linked to any library, then you will understand how
to fix it, how to link it. That is a reason
I have not fixed it earlier so that if
I would have fixed it, you would not have hit my case. I would not have got error. In your case. You
wouldn't have got it and I don't want anything
to go in backlog. That is a reason I have
not done anything. I want you to
understand each and everything and how
to fix everything. So now let's link
the blue graph. Now let's build and run. I should get a linking error. Yes, I wanted to linking header. You can see here in the
console or in the blog itself. You can see undefined
reference to WSS tech startups or whatever functions we
are calling water. When those startup, the Lewis has started
then socket everything. It is getting an
undefined reference. Why? Because I've already
told you for the Windows operating
system and you poke on the socket programming
as well as client. Since we are using
different functions, we are using the
functions which are defined in the wind
Socket Library. We have to link
in our project to that library
nonlinear fixed edit. Because we have
building that library so that execution time
on the linking happens. Linking always happen whenever you are executing the code, then only the definition on the function
wouldn't reject fame on neither declarations
or whenever you're calling your
functions at compile-time, it will compile successfully
because I put a check on neither declarations
that had been received from the header file
which you have mentioned. You it got all the declarations for you, didn't get any error. But in the linking time it
will see the definition. This, you don't link it. You, you will get the
undefined reference that by executing. Now let's see how to
fix these errors. Well, obviously I'm not. I have removed those settings, build environment
settings, so I'll show you from scratch. For that. I have showed
you how to do that. Both settings go-to compiler, your go-to links
or settings step, good, you are having
other link options here. You need to give this library, this libraries for
Windows socket 32-bits. So this is for that. You have the user when
Socket Library and therefore you are doing
thinking and give me minus Lusaka do then just
save those settings. Now when you compile your code, it should compile successfully. Now it is saying that
see this message, we have given this name
for incoming connections. We have given this message here, actually C-out listening
for incoming connections. So sad, what is listening? Now? We supposed to write that code. So I said workload is running. Now, always remember, we have to reinforce the
server code and then climb because server is necessary wasn't without server
port if you directly run to be a problem because this is a one client will
be, I'm integrating. It should be always, you should always launches. And here I will be showing, since I told you that
we will be seeing the socket communication between the between server and client. Here, you can either use, you can run your server in one host machine that is one laptop and you
can learn language. And another laptop that is an another host machine
that is remote hosts. And you can do the socket
communication I'm having. I will be showing you how to do the socket server
client communication in a single machine. Suppose you are having
only single machine, then how you can perform it. So that is also possible. It is that you have
to do some settings, how you will create a server
process and client process. In this project, we
are using this IDE, which we are using
is code block IDE. We have already created
a project for the sudden that in this block IDE. Now for the client to create
a project for the client, we cannot create the project. The client in this ID itself. What that is in
this code block ID. In this instance
it says we cannot clear because at one time
one need this code block ID. We can execute
execute one program. We cannot execute two projects. I mean to say we cannot execute my picnic
projects in a single, in the same instance
on before block. If you want multiple
projects to be executed, then you should launch multiple
instances of food log. So this is only one instance. That is I have clicked
onetime code block ID and I got this instance. And here I've created
a project possible, so I cannot create another
project POC line and same instance on
the coordinate ID and do the
communication for that. You have to create them that you have in the code block ID. Create another instance of
woodblock ID and you have to write buggy code and then you have to do the
communication between them. So by default, you will
not be able to create the second instance of
the code mole sodium will be on event time. So clicking on the word
love to do to get new, new instance you will not get. Because by default the settings
is made in this manner that every time it will be launching the same
code block ID. But now we have to
run server and client in different woodblock
independent since upward loop. So for that you need to, you need to do the settings. I have already done the settings in my case, but for your case, I've been showing
you before writing the server program as the double-clicked on
the code block ID. And you have to
do that settings. And then you write
the server program, which I haven't done
yet, which physio? And then you compile the code, you run it and then second time and you click
on Code Block ID, you will get the second instance offered and you'd be right, that line code, the settings
which I'm showing you. Remember, you are supposed to
do it before writing them. Cerebral inhibitory,
full assignment, new double-click
on code block ID. You have to do the settings.
So how to do that? We get the multiple
instance of woodblock ID. Thus go to Settings. Then you have to go to water and water admit I've
already done so. That is a reason. Already the changes that are already there,
which I am done. While your case, you
can see here allow only one running
instance which is here. The check box will be checked. It will be checked. By default, it is checked. And I have already unchecked it. Because I have
multiple instances. Default, this check box will be checked for allowing only
one running instance. And that is a reason every time whenever you launch
code block ID, like getting the same
for block launched. Since this is check by default, I have unchecked
it because I want multiple instance
also the next thing that is used in already running instance that is also
checked by default. So just uncheck that also
you as opposed to uncheck the align on the man running instance as well as
using already running, unchecked both of them, which already I have
done that where you cannot see that
check mark on that. These settings are
required and check on it and then click on, Okay. Now I will create another
project for the client. And you can see
now it will allow me to create another project. I had again double-clicked
on code block ID, I got the new projects. So you can see one project is the one that I haven't
written the server program, and this is the another project. So it allowed me to create another instance of the woodblock not
project, it is allowed. So this is a one instance
of the coordinate where I have launched another instance on the codon by
double-clicking on it, I didn't get saved. Instance running.
State launched. No. The project for the client. So click on File,
select New Project. Click on Console
Application steps as team, just so you have two
dental cplusplus selected. Click on Next, give
socket programming. Then click on Next. Click on. It will dump a default
HelloWorld program for you. So I've already written
outline program and just copy paste here and explain you
line-by-line instructions. I've copy pasted here. Client-side coding is very much a CDF to simply connected. We'll see in just a second. Let me increase the
font size so that you will be seeing you. Let me close this so
that you can see more clearly whatever
instructions I'm mentioning. This is that line program. We had mentioned
though, credit files. Since we are using, we are doing for Windows
operating system. Now again, the main
function which you know, it is an entry point to start
execution of any program. You have to dump the
code here itself. Even though you can make
your function modulo, you can simply define all these things
in some function and you can call this function, but always in from the
mean function on new, you have to wonder function simply year I've done the code. I know you might be a metal. This WAC data, which
I've already told you, this structure is a second
argument in this WSS startup, we know what is WSS stacked up. It is used to initialize
them and Socket Library. In the first argument, the program tells
which version of the wind socket library
if you want to use it. Since we have to use it, wanted to use 2 version
I've been socket library. This is a false argument and second argument
is the structure. This startup function will fill this structure in which Devin
Socket Library Could pass. I will send the communication about a political information. It will send to
this program about how many number
of sockets can be created in other information, this structure can be fed when we call the bluesy startup. This structure we have declared, declared the variable of the structure in this
manner, WSU data. Now the second
object which we are creating is for the socket. Since me I'd be called
creating a socket on the client side and therefore VR in her
creating available on that. And then we are creating
the video before this but also structure because we will pass the order details. We've been IP address and the port number to which the
client should connect to. It should be connecting
to the server. So we have to write
that on the IP address. So in our case,
since we are running the server and client on
the same host machine. So the client side
should connect to the local boost
because in local host means in the same host machine, same was machine because in which the clientele
needs surface running. And because we are running seven and client on the same
host machine, therefore, we can simply give the IP address on the
same host machine that is a loophole,
wants to machine. The client isn't an input
servers running that it said you have to give the
same port number which the server
is listening to. Now I'll be following
the socket function. We had. I think the first argument
which I already told you, that is an Internet
address family. And second one is that
the socket type stream. Steam is unreliable
type of the socket and all the details about
the socket we had seen in the socket basics,
what are the features? This gene socket is reliable. One, right, is reliable. Everything I mentioned that. And then third one is a communication protocol
and stream uses a PCB default is 0 value. Now this socket will return
a descriptor to that socket. Descriptor that you
got you will be in when you bought the parent function,
you'll find pauses. As an argument of this, this socket descriptor human
past as opposed to argument. So what does these three things? Again, you want, since the client will be
connecting to the server. So clients inclined,
we have to fill all these details about the IP address and
the port number. Since I already told you
that server and client, we want to communicate through this all given the
same host machine in the single laptop, single deck slope itself. We don't want to remote host, we don't want to laptops, cerebral client and
learning. I'll indifferent. Different laptops know we
are doing programming and same host machine and saved
machine itself and therefore, what IP address you
will be giving in the line side, simply, we want diabetes of
the local host because local host of adding
the client is running source servers running quanta
running on the same host. When you are given this manner, it means no back edges. I've explained you that also
in the earlier session, it means it will
be connecting to the local host IP address
of the local news, whatever it is that we
have to solve that. And then we are giving
this address family and since insight of what is listening to the port
number 45555 and depo, we are giving the
same port number. If you would have mentioned
different port number. You don't have mentioned
that port number here it says on the client side. Then we are calling
the connect function. Connect function. We're passing this
first argument as this socket descriptor, which we got from this. And then in this
socket descriptor, Then second thing we're
passing this structure, then size of that, just
in the client side, we have to call
disconnect function. And once the client calls
the connect function, and once the server
accepts this connection, then the communication
from server to client, client to server can happen. Broadway communication
can happen. So here I'm simply sending it. You can also call the
receive function. But I had made it very easy by calling it on either
side function. So I'm sending this mental map, sending this hello you insane function and passing
this descriptive itself, and then passing buffered it, I have initialized to
the value that is hello. And then size of debt. Then I'm closing the socket
cleanup we have seen. It is. In order to close the
socket in case of Windows, we're calling these two
things to resources. So all these things
are required to close the socket connection
in case of Windows, I have explained you what is the purpose of the
cleanup and it is this is how this is the
whole product line site. Or let me compile this
code now click on Build, the parent, no arrows. So I think I should get the linking error
because I'm not done any linking setup to link
to the library when 32, your build and run. Okay, I have already
done that is the reason. Just a second. Let me cross checkered
settings by-law. Okay, this library
already is added. Actually, we are creating
the new and we are creating the new instance. These settings is already not. So that is a reason you
didn't got any linking it. Okay? So you got output here. This 2 second, this client, we have launch client. Now you can see we got the very first message
is connected to server. This message comes once the client side is
sending the connection, and once the server
accept a connection, then only you get this
message connected to server. So what happens is so
accepted the connection. So you've got this very
first message from the UK. Nine, it is connected
to the side of it. Then in the side of a client side we are
passing this message Hello. Client is sending
this message hello and we have all the receive
function from the server. So it should exit this
message and should print it. This message which we have, we are sending actually
from the client side. We are sending this as
Hello and undecidable side. Let me open the
server-side code. This is a server-side code. It is receiving the
message from the client, so it is collected on the buckle and we are printing it on
the sidewall cytometry, see the console on
the server side. So when you see the
server-side console, you'll see it say, it says client disconnected. It says net client is saying hello sources decline faster. Hello message we have seen and that is received
on the server side. And because I said virus has, but indeed that message
on the console, like lion says Hello, see in the service I was hired. Whatever it has received here, it was connected in Buffalo
and then it is printing. Here's client sees what
supply descending. Hello Dakota, it is
printed on that side. So that is the reason
you got hello. This is how you may have seen how the client is
connected to server. And I think passing a
connection to the server, server is accepting it. And then client is
sending the message and writing the
messages message sent. And then set about is receiving that message saying
that line said hello, and then we are
disconnecting from the then the client gets, got disconnected
because we have called. It depends upon how you have executed editing,
your program coding. We have since we have close
the socket of that client, therefore, it has
been disconnected. But always remember,
you cannot close the socket for the server and tell an analyst you
don't close the socket, the client because servers
on either one to which all client will
be connecting to. It doesn't seem like a demon. This is how we have seen
the communication of the socket sidewalk nine for
Windows operating system. I will tell you bought gone. You understood it and he
had seen the execution of the lecture.
I'm done for now. Thank you. Thanks a lot.
12. Socket Session8 ProgramExecution ServerClientCommunication Linux C Part1: Welcome to this new session for socket programming for Linux. So here in this session given
me writing the code for the Linux system side of our client socket
programming and we will be also executing it. In the earlier session, we have written the program
for the server as well as client using C plus
plus what the windows. And we have seen how to create
a new project in the IDE, in the block ID for the Windows and multiple setups
are required prior, accompany and executing the
program for cybercrime. We have seen and we
have executed it. We haven't done the
communication sidewalk line. Now we will be doing a server, client socket
programming in Linux, VM Linux system
using C language, and we will be also executing
it prior to the session. We have also seen mortality
difference or not in the methods for the
Windows and for Linux. And then at a very
minimum difference and set up what changes are
required for the circuit. We have gone through the
presentation and explain, you. See practical advice. Let's start here. The setup very first setup
required is you have to make sure you aren't having valid
index system in your case. And since we will be doing
the program so you don't need to install any code block ID. So here itself, there are ways
you can write your program either if you want to execute
in using the Dui window, you can install that. I have used a simple
command prompt. So what other things
are available by default in Linux or
have you started self, I don't need to install anything required because
already for the Linux, if you talk about the
linears directly, you can go to the
command prompt. If you are having GCC installed, by default, you
will get this GCC. Gcc is a tool to compile
your, the program. And you can also executed whatever output
you will be getting. You directly can execute it. The holder, this
output, this created. So I will be showing you each and everything
step-by-step. Also. In my case, I have shown you those machines since I'm having this laptop is configured
for the Window machine, I'm not having enough. But who make you explain? Who have you write the code for? Server, Client or Linux? I have also I have installed in my Windows system itself
or the Linux VM met. So we embed, you might be knowing it is a virtual machine. If you are having different operating system
here, in my case, I'm having windows, but I want to also write the
program for the Lena. So if you want for the
cross-compilation, if you owe one is different
operating system you want, you have to write the program. You can directly
install VirtualBox. And from there you can write, you can get a download the ISO, ISO image for the
operating system you want. So why my case I wanted
for the Linux system, because I wanted to
explain you socket server, client code communication
and execution in Linux. And I already have
Windows report. I have downloaded ISO for Lena so far you it's nothing
all that is required. You are having a Linux system. You can directly write the code. You will be having
the Communists decided Hat Linux system.
I'm having windows. But to also execute the
program for leaners, I have to install
the VirtualBox. Just consider you are
having the Linux machine. So even if you
install VirtualBox, if you are not having Linux, you can download
the image for that. And if you have made your
machine configured to linear, so this is straightforward. So here also, just
consider you're having abdominal for
the Linux machine. You will be having by
default determinants. Let's see how to go. So let's see the preview, what all things you'll be
covering in this session. There are different
socket methods of other server just
to repeat and chart. It creates socket. In server side you have to create a socket, then
you have to find. So all of these methods are common to that
for the windows, just in case you
can see that it's one method not present
in case of Venus, that is wx, a method
WSS data function. That function was
dead on NAEP or the Windows machine code as well as for the
client would bet. Alina's, I've already
mentioned that WAS startup, startup function which is required to initialize
that have been targeted library is not present in case of this Linux machine
that is only the difference. And these other functions which are there are almost same. Just that part
disconnecting Nina's. The syntax will be
different and there is some structural difference.
So I will show you. If the client socket
methods again, the same thing WAS data
function is not there, which is specific to Windows. That is to create a socket, connect to the server and receive data and
then disconnect. Then the methods and
structured data specific, new, specific to the Linnaeus know WSS Startup function
using Linux, which I told you this has
been done in Windows, then the closing function
is also different. In case of Linux, the Soviet have to just
call the close function. But in case of Windows we have seen we have to call socket. And that is also WAS like Nina required to
disconnect the socket. So all that function was there
only for Windows platform. In case of the Linux we are
having disclose function. Then the type of the
socket descriptor that is returned by calling the
socket function is different. So here, when we call the socket function in both
of the server and client, so it will return socket descriptor in the
window been basalts, it was the same type
of socket descriptor is different in case of
linear return in type. And in that case, often
Windows, it returns socket. Here, when we write the program, you will understand it I've
just done or what have you, I have just written
them all down for you. Then there are different. This socket address
structure type is different if little bit tight
differences there. Same methods or
data type is there. Specific to Linux? Since this socket or
destructure type is different. So this stock, you know that this socket address
structure, what we do here, you fill it with the details of the IP address as well
as the port number. Since that is different. Therefore, you know
that product or service idea calling
texted function. So in this, except by a function we use this
archetype, this structure. So since the type is
different, therefore, the, this will change
in exit function also for the client
side we call Connect. So again, we use this
socket address structure. So this will be different. The type will be different on a socket ID was struck dumb, it does use it ionic function. So even seeing them divide
writing the program, don't worry about it then
with respect to header file, the header files required
for the Linux will be different compared to
that of the windows. Now, these other difference, now let's start
writing the program or the server code and client port socket programming in Linux. Again, you out already, I'm assuming you're
having a Linux system here and you are, you are about to write a code. So I have made it flexible. I'm covering each and
every thing here. Even if you write
the programming for socket programming process
of applying for Windows, you can refer the
earlier session and if you are having
the Linux machine, then you can record the session. So for Windows also have covered programming
and execution and four units and publishing
so that you will be in 14 writing the
code for different, different machine or you
become comfortable with it. So that is the reason I have mentioned a difference
and the code in make you understand
the difference in IQ. Let's start. I will open my dominant of the dominant and we'll
be writing the code. Let's open. Just let me write
their personal. Okay. This is my dominant of the VM. Let me go back. So I assume you want, if you are starting the code
boardroom Linux machine, you are aware of the commands. This is like if you are
comfortable with Windows, you can go to the audio session. And if you are, you want to
write a program for Linux, you should be aware of
basic things like ls. What is Ls doing? So in Linux, we mostly
use this command prompt. This is our terminal.
Actually, I've opened it. You can see the name dominant. And I just, you should know basic commands in
the Linux if you want to write the code here, if you want to
understand how to go to back to earlier
directory or to display what Einstein told us in
particular directory. So I am, and you can see my PWD, This is my part that is my name. And I updated the folder name by MKDIR socket programming. And here if I do ls and I have already written
the code for socket, can coordinate socket
several court. So I will open this code
for you in this form. These are two of us. Instead of having C
files, president, I will go through these windows and I'll show you the C file. I'll show you each
instructions which are used. It is almost similar
to that of the window, just a little bit
different is that I don't, I don't want to start writing Internet every
instruction nine by nine, so I have already written here. I don't want to waste
time and writing it. You will already get
sick of it because almost everything is similar to that specific
function difference, structured difference, and a 100 different defenses there. This Ls. Now to start with
the server code, let me open this folder. In the SOC Server Update dot
c. Now how to open this file using this dominant I can
directly opened by VI said about update dot
c. I can directly open this file in this manner. You can see this is the
code for the server code. I'll make you explain. Even if you want to see
through the Notepad, you can go to the
folder and you can go your socket programming I have created and this is
sort of vertical. You can directly open it. Either you can open
in this manner. This is the same pot
or do you can refer that dominate every foot. So anything you can go? I think so. What is mood, how you can have? So this is more clear
actually, you can see here, so let me open it
in Notepad itself. This document itself. First of all alone, I'll explain you how to
compile it for my students. See the program, these header files I've
already mentioned you. This is first of all, the
server code for the Lena's. I'm already told you
the difference in the header files for the Linux and for the Windows and
the earlier session. If you have not gone through it, you should go through
it in order to have more single quotes. So these are the hidden
files used for the Linux, what a socket programming. You can crosscheck later. Then. This is a main function. So here itself we will have a main function where we
have written our code. So I've told you this main function is an
entry point to start. It's an entry point to start an execution of your program. So whenever your
program gets executed, that comes very fast in this main function and whatever or you will
be writing here, will be executed line by line. So let's see here
what we have done. So you can see here there are two variables by the
name server and client, and I've initialized to 0. Its data type is integer. This is a difference
actually post that is here. You can see here, this is Linux specific data vendors variables, server and client is
used here itself. So these are the
socket descriptor. So I told you in
this presentation, then we call the socket function the socket descriptor
which visitors returned. Its datatype is different. It is type in digital
in case on Linux, but in case of Windows, he had seen it as of
their types socket, capital SOC, QE2 socket. So I hope to you walk through that session if you want to
be specific for Windows. So this is a buck. These are the descriptors. So by this on me, my this
socket handle only descriptor. You will operate on the
socket tube and you call the different
functions like buying, listen, exit in the board. You will be using this adobe cause socket
descriptor for the server. This datatype is different. Again, the second thing
here I told you that the address of the socket
structure is different. So you can see here we
are writing struct. This, this type of structure. We are creating the
variable of it. That is server ADD
at this billion US. This is also Linux specific. This is different if you
compare to that of the windows. Now here, this structure, it is filled with, it is
having so many members in it. So I've told you
my dismembers are used in the because what happened in the
side of our side, I have told you we have two. If one, server and client
communication to take place. We have to cost of
buying the sidebar. If you write the code for
server, for the sidebar, it should bind to particular
IP address and port number. Once we bind that, that means, in that case, the client wants
to connect to the server. How I understand actually what is the sideways
we've had is the server by just
thinking with it, with the IP address
where it is buying too, as well as the port number. So therefore, the
reason we have to, whenever we are writing
the server or you should bind it to IP
address and port numbers. Intimate client wants to
connect to the server. It will be connecting,
it will be sinking with the same IP
address and port number to cut communicate with it so that this is n here what
we instructors doing, the server address, we are
filling the structure that IP address and port number
where the server will bind to. Therefore, this function name it as I have explained in detail
in audio session also. And I've gotten the
methods which are used for the units and for the windows with discussion
singing with a port I also, you have gone through
the session. Now. You can see I have written this IN ADD or any
underscore and you have explained you it same
thing actually if it is banned for Windows
also, what does it do? It means that it is binding to all the network
interfaces which are present in that host machine
where server is running. So therefore, that means if you are connected
to the land, it will have
different IP address. So that is one
network interface. If you are connected to Wi-Fi, it will have different
IP address address and that is different
network interfaces. So your sidebar will bind to any of the odd all of the
network interfaces, whatever you use
in your machine, who wisdom in this machine where you are
running our server. So it means that so
that we are giving this variable, we're
assigning this. And then we add writing
the port numbers. All times fight
this port number. So you can use all the numbers
which are greater than 102465 by three pi because still 1024 it
is already occupied. So if you use any port
number greater than 1024, so whatever you will be using the port number for the
sidebar where it will bind to. For the thrombus mindset, you have to connect to
the same port number. And this is a family
infant address family. So your air in it. So since we are using
IPv4, default, by default, if I underscored ion and this is the bind function.
We are using. This, we're parsing
this disk side of eye socket descriptor. And then we're passing this structure which
we have failure. You have to build
this structure here. We're passing your TO typecasting to this
types and update this. Then we're mentioning the
size of this structure. Then we are calling
the listen function. So we can see same
functions are there for the Linux also just type
differences that it is returning in type
socket handle menu. Again, it will be
listening in the passing this socket handle here
in the first argument. In the second, how many
numbers you want in the waiting queue for the connection requests
for different lines. So here, since 0, I don't want any other
client connection to be in the queue,
so I've written 0. You can modify your code apart depending upon the
requirement human poetry, and action from the
client to be in the tube. The current one is executed. You again give,
give that number. You will listen. Listen means it will be
listening to this socket. Then here we are
printing the message from the side-by-side that is listening for
incoming connections.
13. Socket Session8 ProgramExecution ServerClientCommunication Linux C Part2: I'm declaring one variable. I'm, this is n string type because it is a character array. Here in the exit function
I'm calling exit function. So once the site of
a buns declined, send a request to the server. It will accept it and
meant it accepted. Then whatever will be posted, we will be passing
the same socket handle which we got
from this socket. And the structure here, this is here we are
initializing as null and null. Here it will return
applying descriptive. Here, this will be different
than that of the right. As I also mentioned you, the socket handle which is
returned from socket function. It is used so that
it will be engaged in accepting the connection
from the client side. Whereas this socket handle, which is returned from except it will be engaged in read and write operations from
the network, the client. So both of them
will be different. One use for the
different purpose and also they are different. So this socket descriptor, which we get, it
will be related, maybe having the
data of the client. So even if you can use
independent manner, you're here and I
will be reading. So client is using the same type of board wherein we have seen
from the Windows. Client is sending some
message, say hello. And then this is the set of odd. It will be spin it accept the
connection from Dr. lines, and it will be
reading the essays from whatever the
client had sent to it. So here we are
calling the function. Here we are using
the read function. If the client descriptive
and this buffer. Here we have already
declared this variable and whatever client set sense will be collected
in this buffer, and this is the sizes
you're mentioning. Then I have printed this buckle. That is the message which
declined, descending. Then mm said, but by
doing it 00 this buckle. Now then I'm closing closing the socket which
is there for the client, and then client disconnected. So you understand what we
award except function, what it returns will be heavy related to
backplane socket. After the usage, I'm
disconnecting it. This is what we are doing. So in all most all the
things are similar. Do that Prado Windows
machine that we have seen? This is the code for
the server side. Now. Sorry. Oh sorry. This is this is an
old prejudice for overboard. Let me open their dominant. Yes. This is the code, I hope so you are aware
of these commands, which means if you want to
open through the gum on from, you can use this editor VIM, and you can open the file. So these linears come on. I assume you might be aware of if you are writing
the program in Linux. And all the methods I've
explained you which are specific for the servers, so we'll compile it, but let's see how to
compile this code. We have to use this
GCC, so I haven't, not installed anything
in this Linux machine. So really this GCC, It's a basic compiler tool
for compiling the C program, are directly available
whenever you install. Whenever you are
having Linux machine, you will have this basic GCC, pleasant the air so that
you can compile the code. Gcc, you can compile the C code. I didn't write everything,
just type gcc file, which I have shown you
what the server code, how to compile it
in the command from GCC and then this name
of the file and ankle. When I do ls, you can see it created a dot out
that this is mine. After compiling the
code which had got. Now to run it, I will
simply do not run. Now let me show you
what the client code. Now also one thing that
I've explained you whenever you have to do the socket programming
between server and client, how you have done what?
The Windows machine. If you use videos,
the woodblock IDE, I thought you would
not in this one IDE, wooden block ID, you know, you cannot create 22 decks, one project, and
one product line. And you cannot do
the communication between them if you want to
do on the same host machine, if you want to do this communication
between server and client on the
same host machine, then that is the same machine. Then you need to open
the coincidence of the woodblock ID in case
of Windows, I have done, I've shown you that it's
upward opening to instance, awkward block ID, because by default it does not allow
and we have created, opened it to instance
of woodblock ID. One instance we have created one project, quartered
or sidewalk, and in another code
block instance we are created at that row
object model code. And then we have done
the socket obligation. Now here again, I will, I will be showing you those socket server client
communication in the same Lena's machine. How I'm using this GCC, I'm using this dominant to
compile my code to execute it. So therefore, you don't
need to do any setup. You just open another terminal. This is one dominant,
wherein you will be learning the server code, compiling the code for the
server and running it. And another dominant we
will be running guard. Once we compile the client code, you'll be running into
another terminal. So you will be too short
or open to different, different communists
wherein you will be running one server was always you
should run the server. So sideways should be always
run false because that is the main Damon. Different,
different clients. So that can connect to it. If you don't run solver,
you run client node, it is not possible, you should not,
that will not work. So sad what should run first? Because client who
connect to the server, Then we'll need a communication stops to run sort
of I didn't plan. We will have open in nominal. I will show you your
let me do research. Yes. You'll be running this inside of our code in
another terminal I loop. We will be seeing
posts, the client port, and then we will be compiling and then you'd be
running the client code. But once the server code, just understand
one terminal will be running Server Core
and other dominant, you'd be done inclined code. Let me open another dominant. Dominant. You have that option. Now you can see
another terminal is, this is another
terminal is there. I will be going
through the code. Does the client code. Now,
let's see the client code. We have already seen
the server code. Again, the client code is
very much short actually. You can see here, does this matches
that line code, this, let me maximize it. This is only the client code. So first of all, the header
files you have to write for the debt will be different
from that of the windows. This is the header files for the socket for
the Linux machine. Then again, the main function
that is an entry point. Now in case I told
you we have to simply create a socket and we have to call the
connect function. And then we didn't
write operation. That is only the difference. That is only the small board for the client as compared
to that of the servo. Again, we will be
writing a site of Salk. This will be the
handle of the socket, which is of type integer that is different than
that of the windows. Here, again, socket address that is also defensive and datatype. Now we're calling
the socket function. So here, always remember whenever we have to do
the communication between server and client should have the same second argument which is passed in the
socket is the socket type. You should have the
same socket type. It can be streamed
type over it can be datagram type stream diapers. Using the TCP communication
protocol, it is reliable, whereas the datagram
it is using UDP, which is not relevant. So most of the time
he uses TCP on me. So both of the service side also usually when
you create a socket, this type should be
of the stream type. And if you are using
here the stream. So both of them should
have the same type. Either both of them to the extreme are either
both of them should have datagram type in order to come in order
communications to ductile, which means
settlement in plants. So we're calling
socket function. First argument, we're passing
Internet address family, then dipole of the socket stream and Lindsey Nicole, the
communication protocol. Then that will return a
handle to dark line socket. You have, you are creating
the socket product. Hindsight. It will. I have edited this
variable name. So I've written the name sort of salt because it will
be connecting to the server. There is a reason but this socket we are creating for them. Client. Again, destruction, which is SO I told you the structure
you have to fill. First of all, in the client
side will be writing the IP address of the
server, which is same. This IP address
should be the same to that the server is bind to, and the port number should be also seeing why I have given $127 No.1 and explain you. This is called as loop back
address because since we are, we are, we want to do the communication
in the same system. In this same system my server is running and my client
also I will be done eating. I am. Therefore, since it is the
same system echo this year, it means that it reports
to the local IP address, which is dead on
the host machine. In this lochia local IP address, the server is only also running. So therefore we are simply
mentioning $127 dot one. That means report to
the local address of this host machine
because we know that our server is running in
this local host machine. That means that it is sinking to the same IP address where the server is running. And the port number is why
five times, four times five. Because here we have buying the server to
this port number. If you would have binders, I bought two different
phone number, say 9994 times nine, then you would have given
here four times nine. Whatever port number you, your server binds to, the client side should connect
to the same port number. This is all we fill
here in this structure. That is this. And then when
we call the connect function, we will pass the first argument is the handle of the socket, which we return from this value calling
socket function and this structure which
we have filled with the IP address and the
port number and then size. And then we write
in the client side connected to the server, because after the
connection is done, then this message will be
printed from the client side, saying connected to this client is connected to the solver. Then we have, since in our program we are
sending the message. We are writing the message from the client side and we will be reading it and
thus server site. What message we're sending, we're sending simple hello. Here. We are initializing this string that is a character
array with this hello. And let me call the
right function. The first argument is
handled of the sediments out of the socket handle and then
second argument as buffer, which we are initializing
to this value. We want this value
to be passed to the server message
to be passed to the silver length of this. So therefore, we are calling the right function by
the right function. Mentioning in this
socket we have to send this message buffer
that is hello to the server from
the client side. This is a client side. Then
we are printing the message. That message is sent up
to calling this rapier, misspending the message
on the client site. But this backbone, and
then we are closing this handle and
then socket closed. So this is the code
for the client site. So you can see this
ready-made, simple and z. Now I have open
another terminal. Let us go to the substance. We have to always run faster server code so
we'll be running it. So I will open. I've run post-hoc
wall server code. How to run it by simply mentioning why I
mentioned this dot slash, because this means I am in this current directory
on the folder, and I will execute this. A dot out, dot out is present
in this folder itself. So when I run, I will
get the server side, this message that is listening
for incoming connection. Now the server is listening. Now we have to run our
client code one meter on. Once we run the code, then client should connect to this servicing
client disconnected. Then client should
send a message to the server and we
will be reading in on the server side you'll
see a welcome message that $0.09 will be displayed
on the client terminal. And you can see on the
side-by-side whether that message is also
read and printed in on the server side in
service I now we can see on the listening for
incoming connection, let us run the client code also. So let me open the
dominant chord. So post I will compile this client code by
simply this function, DCC and the name of the file. When you run, you'll see
just a dot out that is the output produced
after compiling it. Now we should execute it. So here you can see you want the message on the client
side that connected to the several vendors
message sent with buffers coming when the client is sending some message
to the server, then this message comes. So let us open the service. I didn't let us see whether
the message has come there and the information
has been updated. Yes, you can see after this listening for
incoming connection, this one mode we
can safely game on the server site line connected. Client says buffer is hello. From the client side, what I want to say
just asked you are you can print line says
but, but it's hello. And then we have gotten
disconnected function from that also from here. This is what we are doing. You can see how this
communication takes place. So this is just I'm
sending the message from the client and I'm
reading the message, I'm writing the message
from the client and I'm reading it
on the server-side. So you can write and read on the server as well as client. You can have any two-way
communication at allele. So you don't just
explain you the syntax I have I have written from the client side and I've
read on the server side. So you can do Weiss was
I and you can do both write and read and do the check. The chat from server
to client. I'm too. So this is what we have seen, how this socket obligation explains how the message is
sent and what all function, different structure,
different mobile header difference is doesn't. Let me move to the second. Let me, let me come back to my presentation will be done seeing all these
things which are there. We have that we are done with the server, client
socket programming. We have done in C language what the Linux and we have
also executed it. I'm done for now. Thank you. Thanks a lot.
14. Socket Session8 ProgramExecution ServerClientCommunication Linux C++: Welcome to this new
session four, et cetera, client socket programming
and see blood split quarterly nuts
with its execution. So prior to this session, we have gone through
the session for server, client socket programming in C language or Linux
with its execution. So we have written the C code
for socket sidewalk line, and we have done it's communication while
the Linux system, we have seen how client and server they communicate
with each other. Now, we will be diving C plus plus code and the Linux
operating system, and we will be performing
socket programming for cybercrime is no much
difference On need. The compiler will be different. So we have seen, we have used in the Linux for compiling
the C program. You have used GCC yet we will be using on GPS because that
is only the difference. And some functions that we'll be calling quarter
inputting and outputting will be different breast all the functions related to
the socket will be the same. That is no much difference. So we can quickly go through
the session as it is almost, almost similar to the set of guidelines I've been
programming in C on Linux. Just up Jens door. Three functions,
calling functions will be different as it is used, It's fluid to input
on the console. Let's see. Just to show you, like if you can do
the coding policy, you can do coding for cplusplus only the compiler two
will be changing. Let's go very quickly through
the session in detail. If you want to go through the previous session
which I had explained in detail the same program
and see what the Linux. So I'm going here to
ugly because it's simply the repetitive things on
the minimum difference, biological difference, and some calling
functions different. Again, the same thing here for the server socket
methods for linear, since we will be
performing this, that these functions separate
isn't creating the socket, binding it to all
the things if you compare with the Windows
machine will be similar, but one function is not present. For the Linux. That is, although WAC startup and when we disconnect
from the socket, syntax would be the difference
as compared to that on the windows for
the CC plus plus. Same functionalities are there there is no difference
in Texas also seen. That is no different
and socket programming using C and C plus plus on neither compiler tool and some
calling functions related to input and output
are different. We will be compiling
the code using g plus plus here in
case of writing, when you're done writing
the code and cplusplus. And then it'll be executing it. Now near the client
socket methods. Same thing I need to do as
a startup is not present. That syntax is different
than having the same for C and C plus
plus will change. The same thing with Dr covered
in the previous session. That is for the Linux specific, these are the methods and
structured data that is not a versus Startup function
used in case of Linux, as I told you now. Then the next thing,
losing functions different IW or losing them socket. We are calling the
function that as compared to the
windows that didn't Macondo glue socket
in WE sick limit. So that is different
in case if you compare with the
Linux, I'll see you. It is similar, is same. And a dipole socket descriptor, it is driven by calling
socket function is written. So this is a difference in specific to Venus
because for Windows, the socket descriptor and
then return recordings, the socket function will be different as
compared to Linux. We have seen that in
the previous session in the c programming for in the Linux system that we call the socket
function the socket. And then we got, get
the type of the socket handle is of integer
type in case of Linux, but in case of Windows, we have seen it as other types offered capital SOC Katie,
that is a difference. But for CC plus, plus same
functionalities is dead. No change in this. And then disorganized or striped
structure is different. Again, specific to the
Linux address structure will be using for the socket read and really
revealing diabetes. And the port number that
dipole that socket and restructured is
different in case of Venus as compared to Windows. Also a pet related functions
as saying for CC plus plus. Then since this
edit structured as a different type of
decided structure, indifference or
dysfunction is used. And so their website portico accidentally call
the accept function. We will use this
address structure. So it didn't have the
type different as compared to their
doctor windows on. So the client we're
calling connect. So again, incline,
I'm going to be called Connect
function inclined. They said DO structured
is used at the time of the debt is different
than that of the windows. Again, the header file, if you talk in terms of synthesis specifically
not so dead. Polynices was socket
programming is different as compared to that of the header
files. Window selections. I'm just rushing through this session because it
is a liberative session. Just I want to show
you if you compile cplusplus code and Linux and
what combiner tuners used. And some header, since we'd call functions to
input and display, that related calling will
be different. So Socrates. It all functions are saying
has come back to that. If you compare C
and C plus plus. So let us start
writing the code. Let us go through this talk. Cetera gland cplusplus
socket programming with execution of
identities may not exist. Go to the Linux
operating system. And then I will be showing what all things
we will be using. Welcome vital to
write that code in C plus plus n2. Combine it. Moving to the next. So I'm having or
when to Linux here. Second, let me give
the first one. Here. I will be
opening the dominant. Since we will be, We will become by writing
the code in the dominant. You know, I have
already told you in the previous session that in the other tendency
programming or socket communication in Linux, I have already told you that we are having the provision
of using determinants. So if you are having
this setup of Linux, I will show you and having, you know, the basic
commands which are used, or the Linux that is
very much important. So we have already covered WC commands and short in
the previous session. We will be writing
the code dominant. So let me open that. It is launching a minute. High-quality created the
folder boardroom, C plus plus. It's almost seem just wanting
functionally defense in. It says wonderful. And you can see now the
file which I have created, I've already written
the code so as to avoid the time taken for writing
each instructions. So already I have explained
each instructions and previous session
that didn't have written the code in C and B. Next it says go through it
if you want to go in depth. So yeah, just to understand what tool is used
to compile the C plus plus code and what minimum differences they're not
in socket programming, but when you call the console to read and
write on the console, just that function will differ,
whereas socket functions, as seen here, this file which you are
having in C plus plus language will be having the
extension dot cpp that in the Vedas engaged solve the C language when
you write the C code, we had seen extension
was not seen, but in case of the seat, Let's best extension is dot CPP. You might be aware of this if you have done the coding
part C plus plus, let us go to this. Now. If you see that though, if you compare to
the C language, if you competitive less
physical good C language, all the things are same. Just a difference of this
header file I have included in C plus plus because you might
be knowing this I O stream. This is the header in specific bought displaying and
inputting on the console. So like we have seen, that engages on the C
language, we use stdio.h. Here. You can just remove this stdio.h that is not required. So just let me you
can come in here. This is not required. Because here you're
going to be calling the functions that is
display on the console. It, you're calling
the function code. So you might be knowing that
when you write the code and cplusplus display any
message on the console, we call cout function that is acquired outputting
the message on the console. So this message unit
output on the console. And this out it is, I have used the namespace std. You can see I've
added the school using namespace std because this std standard
template library is that this function is defined. So therefore, when you
have two C plus plus, you have to mention in this namespace on this
functions are there. So we have to, first of all, I mentioned this namespace
and then we can see on, if you don't mention
this namespace and using namespace std, it will write it here. Then you can simply write as to the school it as a solution. So these functions, and I assume that you are now
in the C plus plus code. If you entering the
cplusplus coordinate the light that is basic
function to display it. I think this year and give the input on the
console we use C in. So in our case, we
don't not giving any input on the DevCloud. I'm not calling function to input on the I'm calling on me. See, I'll bring their message on the console so that there's only difference
here is the sulfate related functions are same. So if you see that this is a
cirrhotic coordination, you Execute your program. The execution stopped
from this main function. So whatever line of instruction, so we will be diving
in this main function. It will be executed
nine by nine. This is the same
repetitive session, just to mention you the
difference in C and C plus, plus. I'm, I have I'm giving
this session very quickly. The gourd here. As I told you, you'd be calling the sorted function
that is used to create the socket and several court that is Internet
entrance family. This is the type of the
socket it is streamed by. So we have bought server
and client communication. The socket is created
and both sides. So the type should
be same if you want to have the
communication between server and client is having stream type nine dots or you should
have this gene guide. Stream is at a liability
type of the socket here. And the third one
is a communication protocol default value is 0. It returns a descriptor
that is type in vivo. So this is seen in case of cn sequence every
time region which is used for socket programming in C language and as
well as sickness, but no differences that on me, this blue color display and input from the console
that only functions which we will be calling
is different in case I'll C and C plus plus in this
header file we have to include. And then this is the address structure
wherein the side road, we should bind it
to IP address and port number so that when the client wants
to connect to it, it can sync the same IP
address and port number. So this structure
we have filled in the server side with this value. And this Board
numbers are disvalue. That means it is, it can bind to on the
network interfaces. So I've explained you dip
in an earlier section. And then the sport numbers, whatever number you give
should be greater than 10 to four because still
1024 it is occupied. And you can use greater
than 102465535. Then you are calling
the bind function to bind sort of a socket to the IP address and port numbers only at spotting bootstrap data
two-year period here. Then we are listening this I'd rather be listening
on that software. This is how many number it'll outline connection
would be innovating. Then calling the exit function from the set of our
site will accept any message from a
connection from, let's say, accept any line connection
from the line side, that phobia calling
exit function declines and the connection then
the server will accept it. And then filtered version and other soccer descriptor
that is also of type int. This socket descriptor,
if you didn't write vocal all patient and
the socket descriptor, which it doesn't return is you're getting engaged
with dark line connection. This is what happens. And then that said avoid
what we are doing. We are sending the
message from the client. And thus I said we will read it. This message will be collected. We're calling the read function. This message will
be connected into small funds simply
operating, renting. You can see here the difference isn't just what
they're printing. So here we are calling
the function CL, that is C plus, plus
C plus plus language. And yet, displaying on
the counselors C out and this dentin double-quotes
whatever message you give, you don't need to give the format specifier
and C plus plus. And then you have to give
in this index outputting, then buffer, and
then end redness. You want it to appear to this
message on the new line. So this will become incoming
on the new United case on the CV gives slash n. But
in case I'll see bless, bless me, give END l and l that is appear doing Windows newline message
to come in the new line. And you can again, so whatever you can see here, wherever we want to display
Animals eight on the council, we're calling the C0, C0, C0 debt on these different as
compared to the C language, there are two lines
of extra code that is hash include iostream. You have to include
this header file and hash and then using
namespace std, because in STD on
me the CEO is dead. That's it. And then I told you, since we will be performing, said Let him client
communication. C plus plus in the same, indeed nuts in same machine. In that case. Of you'll be opening
the total minutes in one terminal and you get this as a dominant and one terminal, we will be executing
the code for events or discount bias of the
code is compiled and executed in one dominant
in another terminal. Once the client code is
compiled, we will execute it. And another dominant, both of the total water on
them should be running in different terminals and then they will be
communicating with each other. Let us compile this code. So here, this is a
different in C plus plus, we will be using g plus
plus compiler tool. In case of the C language, when we dug C code, we used GCC. But welcome finding
the C plus plus code. We cannot compile
the GCC because GCC compiler tool is used to combine uneasy,
Nazi, blessedness. C plus plus is an
extra add-on on scene. You just g plus plus. That is a compiler tool. You can compile the
C code as well as C plus plus code because
it is an upgradeable, a dozen upgraded version, that of the C language. So C language as well as C Plus Plus language can become filing by g plus plus Y2
outside is not bossy, but that is, you cannot combine your C plus plus
code using this GCC. You have to use g plus plus. So since C plus plus supports, supports C language alone, so therefore by G that
we're using D plus plus, you can combine C and
C plus plus code, but vice versa is not possible. That is, you cannot use GCC to combine the
C plus plus code. So therefore we will
be using g plus plus, and then we will be bilingual
or using the student. So again, it will
create the file and out I had before running it. Let us also see the outline
code that has opened a new dominant or the
accidents I totally butchered run in
different dominant. Now. Now, since I told you
though, C plus plus code, which we'll be diving really
have the extension to pilot inherit the
extension towards CPP, have done the changes for calling the input
and output function. So you can see here, again, we are having, this is a very short
code in a minute. You'll note that the
client code is very small as compared to that
of the salvo against the socket functions
as saying plus aqueous plus four C language
on media calling the input and you're calling the messy function to display the message on the
console leg is only different. Therefore, we have to include
this header file, iostream. You have to write
this namespace std. So same pink rest haunted things are seeing
related to the socket. So you are calling the
socket function in client. And we're saying is
we're mentioning here, so the same syntax, we're filling it
with the IP address. So I told you $127 No.1 isn't Lubeck
address that since we add me wonder
communication to happen in the same machine. Depth or the server
and client is running on the same machine. Therefore, this means a
Lubeck address means, this means this board to the local IP
address, local host. Ips certainly had diabetes on the local host
because we know that in the local host
server is also running, so it will revert the IP
address of the local host. And then we are mentioning the port number in the server-side, whatever number we give that
don't meet the client side, it should be sinking to the same board number in
order to connect to the cell. And also the IP address
should be the same. Then we go on
disconnect function. V bar is this structure here. And then we are writing the
message from the client site. Same message I have written. So you can see the V, V I'm displaying on the
council is different since we are doing this
coding in C plus plus. So I'm using the
CEO who display on the console and N dollars used to have them message
on the new night. Again. See how it is used here to want to
print the message, whatever the client is sending that we up ending
on the console. This differences
on neither rest on the socket related
functions are same. So you can understand if
you know the same language, you can start C plus plus
nothing difference are that in the socket related functions on nuclear display the
message on the console, the C plus plus because
quarters there that code. But pooping on the console. Let us Find the board here. So here are the combination tool I'm using GPS because
as I told you, we cannot use GCC to compile the code for the C
plus plus because gcc, because C does not
support C plus plus, but z plus the support
C because it didn't, It is an embedded
version of the sea. So therefore, you can
use GPS best to compile the C code as well as the
CPP C plus plus code. But you cannot use GCC to
compile the C plus plus four. You can use GCC on need
to combine the C code. I hope so you understood
the difference. Then let us compile
the code here. It is generating
a dot out false. We should run the server, then we should run that line. And what is their
daemon process? It should be launched first in except the connection
from the client. So now let us run the
code for the server. You can see on the server side and we're getting
this message that is listening for
incoming connections, sort of what is listening? Now let us run the client code which is dead
on the another dominant. Now, simply we are
sending message, we're recording a
right function message on the socket from the client, say the server-side DOM
witnessed stage will be updated. God connected and
whatever message the deadline descending to the survey Derby to
speed on to sodium. Then mutual using the socket. Let's Dando by AD and output
inductor underlined site. You can see here connected to the silver on load line site. After the connect function, you are outputting this message using CEO that is a
difference and C plus plus. And then once the
message is sent, ones me write on the socket
from the client side, we get them as statements. It's in with buffer
inclined handle. So let us go to the server
side and see whether the message has been received. You can see here that
in the syllabus, this is a server called
socket several code. You'll go gone this message ductus after listening for incoming connection
on the silver side, if you want them as age
as Glenn connected, client says, but what is hello? So this message, you
are a good thing on the output and then
client disconnected. Here I had one more thing. I have initialized. If you see here, that though we have two backward actually which I'm using here on
the server side, I have initialized to 0. Because if I don't initially, this 0 means it is
initializing on them. And buzz of the eddy, Brazil, you can directly, you don't need to write 0
every 102 ordinal a region. You can simply write
Connie racism 0, that means on the UN
initializing by default to 0. So this is very much
required because once the sidewalk going to receive the message
from the client. In that case, since if you don't initialize
by dipolar to 0, then whatever those
clients have, send a message on the celebrant you output of a new
displayed on the console, you will get that message, but extra vitae, which
thing you will also get. Therefore, we have to first
initialize this string, that is Eric character to 0. And then we have to whatever the client is
sending to the server when me, that is gonna didn't
Buff other and may display in on that
on the console. You will not get
the database venue. What you get so client
is saying only Hello, so it'll get her lawn. This is yes. Now we are done with this
socket programming board. Decide about applying
come vacation in Linux platform
using C plus plus. So hot drink C code. You can go through the
previous session that I've covered in detail. I'm done for this session. Thank you. Thanks a lot.
15. Socket Session9 UnderstandingHTTPServerClientCommunication: Hi, welcome to this
new section that is understanding that
should be server client communication on ECP. Here, again, the socket
communication we will be seeing between the HTTP
server and client. By the term HTTP, you might be aware
of what is this? Http. Http stands for Hypertext
Transport Protocol. And whenever we are
surfing the net, whenever we want to etch some
information from the net, we will be typing the link, will be visiting the site and we always give http or HTTPS. By deck, we will get the page launch link
we get in this manner. The information weekend fetch. In this manner, whatever
link you are passing, you are giving on any browsers. It can be the Mozilla, it can be the groom, it can be Internet Explorer. All these are the browser types. These are the client-side, application side so that we will be giving any of the URL, this URL, which will be Odyssey
link, which we, you give, suppose you are
giving Google.com and that is what will happen. You want to fetch the
page on the Google.com. So you will be a link on, you will be typing the
link on the browser, on the application
side underlying site. And this linkage us passing will be sent
to the server side. It is Apache,
Apache server side, and it will send the data
in response to the request, which is ridges given
from it was a side. So then the data will be
loaded on the browser side. This is how this
communication takes place. We have mostly go
and dive the link, but we don't know how it
works in helping manage this communication takes
place was simply be one summed data we fetch. Suppose we want to fetch some image to even be
typing the link on that, on the, on the browser. That can be the problem can
be genetic soup explorer. Then we will be getting
the data of the image. So how does data you
will get on the image? How this happens actually, you're just typing the link and you are enriching the data on age on your page, how this data you get. So behind, this communication takes place between the
server and client and server. A mutation takes place. And that is the HTTP server
client communication. So this takes place on the TCP. That is, we have
seen TCP session. It is a reliable protocol because everything
is provided here. It provides the
error correction. It is reliable because all
the data will be sent. Some of the data gets lost, then again, it will
be transmitted. It can be also notify
the set of us. So this is how reliable
communication takes place. It is also heavy weight. So we have seen, we have discussed about DCP. So here we will be seeing how this HTTPD be several
client communication takes place on TCP. So it does not take on UDP
because TCP is a reliable one and we want the communication to take place, it
should be unreliable. So therefore, it will
take place on GCP. Let's understand more. Let's go to it so
that you will be understanding in detail what
all we are discussing about. In our earlier lectures. We have seen, you might
be aware of how would this TCP server client
socket communication takes place because I have already explained what
well-known methods are used. Or TCP server, client
socket communication. And we have also seen that with code for the Windows and Linux, we have all sorted in the
program on the woodblock ID, this TCP server
time communication, socket communication,
and the windows. And we have executed it. With the help of this knowledge, we will be seeing how this HTTP server client
socket communication takes place on TCP. So this will be
very easy for you because if you have gone
through the earlier sessions, you will be at all, almost all of the
chord VI using in this socket communication of
each HTTP server offline, but with some little
modification. So you will be also finding
it more interesting. And let's begin the topics
which will be discussing people's understanding the
blog diagram of a medication. Then we will be seeing
how the HTTP client sends the request in the form
of the head and the NBC, What does this header in detail? Then we will be seeing how
this HTTP server will give this bonds to HTTP clients request in form of
header and body. Let's begin with the topic so that you will
understand more better. Now this is the diagram for HTTP server outline conjugation. So here you can see
this is HTTP nine, and this is the HTTP server. The request will be sent
from the HTTP client side to the HTTP server site in terms
of HTTP request message. And it's typically sidebar
that dance it receives don't. Um, input the data
from the client. It will produce this on it, then it will send
the data response to it to the HTTP client. So blindly considered
as a browser. The example which I
told you you weren't any link on the delta. The browser can be though room, it can be the infinite exploded, or it can be fired false. So different,
different browsers. You can giving
different links wherein the link is containing
HTTP colon slash. Let's suppose you
and you want to give the link WW, the
moodboard, google.com, you want to give facebook
bought common standard, I'm dot com any of
the link but you want the multimedia
related link. Whatever information you want a link to that you will
give the different links. That link which you pass in. That will be the
result client side. So that will be the link. That information will be sent to the server site
instead of on the site, it will response to that link. It will fetch, it
will constitute the data which it should be sending to the
client so that the, that data that was a site on, that data will be
loaded and you will get the page loaded on
your browser side. So all those data, it will be sent from
the server to client, which should be loaded
on the browser side. Let's begin this other
diagram, opaque. This is your web
browser, as I told you, it can be Chrome, it
can be fired, false. Sephardi, Internet
Explorer, anything, any of the router, this part is the client and
you are passing the request. That is, you're
typing any link on this browser like Google.com, facebook.com, and
today internet. This will be going to
this side where it's sort this web server
and application server, that is HTTP server, this mini constitute the data. Actually it will get the
data and it will send it in response to this request
here to the browser, and then page will be loaded. So this is how the
communication takes place. We see more detail now. Now let's understand what's happening in the
previous diagram. So HTTP client, let's send
the request to the server, will respond to it over TCP. The same thing which
I told you that this client send a
request to the server. That is here line, this is a client and
the server decline. That is your browser. It
can be any of these things. Chrome, Firefox, Safari,
Internet Explorer. It is sending the request, HTTP request that will be
passed over the TCP protocol. So this request will
be sent to the server, will respond to it, sending the data back. It will respond to
it or whether TCP. So it uses MQTT protocol, it uses TCP protocol because
it is reliable protocol. Tcp protocol is a
reliable protocol. Now let's see the example, the one which I've already
discussed, the browser chrome. See you when we give any
water to say we give http, www.google.com, adobe eyes,
giving any of the URL it. Suppose you are given the URLS, the Buddha
blue.example.com. This is suppose some link. It is having the default page. This link has been configured to have the default page whenever
the user type this link. This link itself
is configured to come to this page, default page. If it is configured
to this page, index.html, any of the
links actually it can be. Then what happens? So let's see. This UID, it will be
passed in this manner. This you added will be
passed to the server. This overbid process it and send the data back in response
and the page will be loaded. Let's see, one-by-one,
what happens? Now? We will be discussing
step-by-step. That is, how HTTP client will send a request
to the Apache server. So we have already, we're
discussing the example like we are giving any
link to the browser. The browser can be anything we have seen in
the block diagram. Suppose if you give example.com, as I told that some
of those links, they are at the ADA or default
configured to some page. Suppose this page, example.com, it's configured to index.html, that is, its default
played your venue. Give this link
that equality will be that human index.html. Then this link which you give on the browser what
will happen in that case. In that case, you would type
any link on the browser. And that gives us a GDP. That is, if you give
http WW.example.com, then STT pick nine. Ms, send a request
to that server. This you added a little bit
past to the Apache server. Here I mentioned this test. The data is sent to the server and this data that is this UI. This, it will be sent in
the form of the huddle. What is this header? Each and everything I
mentioned, the header. This header, which it is there. It will show up different
things in it. There it is. It will consist of the methods that are different HTTP
methods that are available. We will, we will be just seeing the list shock methods
which are available for HTTP at the very last
end of the session. The one that's going to
be using is a getMethod. This header, it cancers. If we are talking about this URL which you are passing
on the browser, on the groom, say you are typing any link, say WW.example.com. And what will happen
in the background. So postdoctoral in
the background, this HTTP client will send a request to that
practice over with this UID, that is W W.example.com. And this, there'll be
unwanted of either sending this request or their
practice at this client. It will convert this URL
in the home or header, this header it ancestor of all these things that S
is consist of method. There are different
methods like get, delete, the different
different methods. But the one which Is this, the getMethod will
see what we are all different methods to get
this to fetch the URLs. So therefore, in our case, since we are giving the URL, we're fetching the
USDA via using a year. The getMethod will be
fast. In this case. Then we'll be done. There. There will be
consisting of the method, and it will consist shop URL. You added it will be, that is in our case actually
died example.com. But if it is configured to some different pay
say index.html, then b hat, and then
the protocol version. Since is that we are
using the HTTP protocol, so it belongs with answers
from the protocol version. Then it will come
since the host, host will be like
WW.example.com. It's IP address for who build anything you are
asking what will be the host address offered that
month and the user agent. So this nu is that agent. It will be new for you, actually are whenever you
are using Mozilla, Firefox, or Internet Explorer, just understand that
different, different, different, different,
different, different user agent API using, if you will, you also
can test in this manner. You just try WW dot examples. The bill.com on Chrome browser and you check the user agent. You type it on, the fire is false, you
see the user agent. So it will be funny to
have them depending upon the dipole goes that
you are using VDC. The next slide to discuss more
about this header details. So I hope you understood
that when we are sending this new URL
link to the browser, actually buy in background, this browser will form on
this outline performer. And it will consist of all
these things which will be passed to the server in detail. I told you this header cancel
stock method actually, since we want to fetch the URL, the method will be
the GET method. Then the URL actually which
you were typing actually, and the protocol version, which type is GDP
Virginia using. Then you host actually what is a host IP address
and the user agent, as I do it for
different browsers, there are different user
agent on it see in detail. This is detailed in this
manner. By this thing. You will understand it and motorically or so
this is the header. So in our case we are
fetching the URL. Since I told you four different, different methods that are different HTTP
methods, in our case, getting method only
gets called because GET is used to fetch
the URL for this, you will get this as a method. This is a method,
this index.html. I told you that example of
the little blue.example.com, but in other default, zoning is configured
to this index.html. So you will get the URL
here in this manner. Then this header will consist of this protocol version of HTTP. Then it will cancers
the host or hostess, WW.example.com, which
we are parsing it, then the user agent. So this is a user agent source. I've always be at writing. Giving the link on the
Mozilla Firefox user agent will mean this man was a codon then it would
have given different. But on an inversion on
syntax on that user agent. And all the details about this, except language
disorder, these things. This is all the
header constitutes of all these information will
be sent to the server. So whenever you type any
URL to sin example.com, it has the call
configured to this index.html on the
Mozilla Firefox. Then internally this client will form this header in
this manner actually, and it will send to the server. Now also when we will
be doing programming. So here I'll explain
each thing about this HTTP server
client communication. And in the next session we
will do the programming. When I ran the code of a. Of you will be seeing
all these data. We will be printing
the data what does descending to the sidewise. So this data will be
printed on the side-by-side so you will understand
it more clearly. These are all the
things the client sends to the server
and you can get it printed display on the console of this
advisory board message it received from the client. Then this we have seen
now what happens when the HTTP request to that
server now see workmen, how sad, but it will send
the response to this guy. Now, this side of it has to see this header which the
client had sent to it. Now this outside where
that is Apache server, how it will respond
to this client. So it should also
has fallen by 70. The data in terms of this
header format, in this form, I told you should send it so that on the page
you will get it. Get the proper page
loaded with information. So this album, what
DO NOT IN case of the sidebar it constitutes constitutes on this information this information which
is which this side, wherever it should consist, stop if it is possible, there will be the protocol
version, same as GTP, which version it is using them, the status code and message. What does this, that is whether the link which the
user has given it has been successfully the sidebar
This morning successfully. There is any failure of the
network, anything, whatever. Successful failure dependent, dependent of code are
their message are there for that failure success and many different messages. So it will send
there it actually in this header that we
will consider report all this information it should consist and the content
type and content length. So what is this content
type and content length? In our case, we are giving the WW.example.com or default that link is configured
to index.html. Suppose so this index, our content type will
be of HTML page. Suppose it was some image, then it will have given
the content type is image. And what does this
content lends? Content land is how much
of the data is received. How much of the data ascending actually the server will
send to the client. That says the content. And this will be followed
by a blank line and the message with server 1% to
decline that you can write. What we will do in
our next session, we will write a program
for this server. We don't need to write the
program for the flight. Be using all the methods which
we have studied till now. That is for HTTP
server communication, instead of US aid whatever it's required to create a
socket to bind to, Of, listen to accept all
those coordinate will be writing and some
little modification actually that will be
this modification. So since I've been
with you, since, I'm telling you that
the server will respond in terms of produce. So since we'll be
writing the code up on Leda side-by-side, then mission. Write all these things. We should give this information from the server side in our code so that we get a proper
response to cancel, we get a proper page. So whatever message we are
typing on low side-by-side, we want that to be
displayed on the browser, but in the document said should be printed on
the browser side. Suppose we are sending
high from mom, the ascending hi or hello, buy anything from
the server side. It should be displayed on
your browser page as hi, hello, whatever message
you are sending. But we have two kinds. We have to not sense
and detect texts. We have to send it in
form of the header. And what this header
will cancel stop. It will consist of
protocol version. You have to give the HTTP
version in our old server code. Don't worry about this. Explain you with the board on. So this is just a description
so many start boarding, I will explain you what coding is required
and it is very simple. It only two or
three lines of code extract gold is required
to perform HTTP server, client communication
since you already know what is the
sidewalk or doc TCP, we have seen it in
our earlier session then just do the lens is
adult and it is simple thing because what we have
to simply constitute the set of vertical or fight, we have to constitute
that the message, what server will send to the line incomes in formal credit. That is only the difference. What did we showed
consists, Alex, I will mentioned you what
all things we have to give a new portal so you can just simply report
whatever I'm writing, whatever I'm doing coding
and you can understand it. What about the ones
you do yourself, you execute yourself, everything you I will let you know what
all things are required. So this protocol version
status score message, you have to give them
content type and then followed by blank
night and the message. So let's see. In this, this should be the format. Actually this is a
format picture or diagram and what messages
type I'll explain. I'll explain you in
the next session. What message will be
given from this side of it in terms of
this header files. So that whenever a given If we give them what we
will do in our case, how do we will run that? You will do this
communication between the browser window,
Apache server. We will simply,
since we are having, we are having the setup
of our machine itself. He wanted to test it, gonna arm achieve that. We will give the local
host address and the computer, the server, to listen on the local host of DynamoDB drive on
the browser side. Whenever we are giving the VI to giving the local who's giving the IP address
saw fired at machine itself. Then in that case, it will talk. And you didn't map to the
same port, server and client. Therefore, once we write the local host IP
address in order, but I was giving the port number sources on that port number where I'm applying this having
the same port number. So we will be by name the server to that port
number, that is 80. And we will be doing
on the client side, this local host, local host on IP address on the client side
and with the port number. Will listen, listen to
that client request. Since the ADA having the
same port number and it is mapped to the same IP address on the server. Should
we listen to it? And it will be accepting it. It will accept the
connection and then send a message to the
client which will be seeing on the browser
side text message. So don't buddy, relax. I'll explain you in detail
in the next session. Just to understand this is the hard data which we
have to constitute. It will be built right in our message from
the server site. Only this message
will be changed from the server's identity to write the entire message will
give the protocol version, and then he will give the status 200 and the status messages. Okay, that is all the
things I've successfully. There is a reason
we give this detail and this information like date. And then content
types of isn't EPA consider the example
of WW.example.com, then it is configured
to index.html. So it is the next type of
market is not the image type, so that is content
type and how much data will be passed from
the server took nine, that is the content Lin. And then a blank line and the message should be sent
from server to client. Say hi Hello by anything. This is the thing composed by the server site at
which this data is a header format which will be
sent to the client in order to page loaded on
the client side. So yes, once this advice center response as
shown in the previous slide, then the page will get load
on the browser line site, but the message sent
from the server, the same thing which
I told you once. The server constitute this
header and send to the client. And then the page will
be loaded on the side, on the browser side with the message with this
side, but it's sending. This is how we will
be proceeding. Now, we are done with understanding the concepts
which are required. And at the very last, HTTP methods which are present there that is radically different
HTTP methods like get, it is to patch the URL. In our case, this method will be used because we
are fetching the URL. So therefore they
GET method will be called when the header
is constituted, then another messages
and header header, that is to fetch the
information for the URL. Another method is put
that is to store to the URL method posted
on data to you. I didn't get a response
back and deleted the D2L. So there are different,
different methods of the HTTP. What, uh, what us,
we just require, that is the gate since we
have to fetch the URLs. I hope so you understood the
concept before stopping. Before starting with coding. It is required to walk
through this session. So basic things we
have discussed, we had seen how
this communication from the browser takes place
too dark side of both sides. That is, over whatever link you mentioned on your different, different browsers,
whatever, then this link will be parsed. That is, a request from the
client will be passed to the server and this
client in background, it will constitute
the header which will contain this format
if disgust you, it will contain the
methods since you have to fetch the URL and then the URL. Suppose it is indexed, suppose it is example.com. Default is configured
to index.html. So that will be the URL, then the protocol version. Since we are using std, one version of it, then the
host that is example.com. Then he was written, I told
you four different browsers, like Chrome for
my acquire falls. Dave derivative in
different new user agent. Then this information in it, then how does that
availability response? So he'd been also
constituted responds back in constituting this
header and body itself. So this header will
consist all these things. So this is required
for our case. We will be writing
the message from the middle rewriting
copy pasting the same or HTTP or phone, sorry, TCP server outline
which we have seen. We will copy the same
code parties is DCP. Dcp several naught
line client coding is not required only TCP server, we will write the code, the same code and
just unnecessary via sending them I saved
from the server to client. Not centered texts
like hello, hi, sand in terms of credit format, in this format that we
have to admit changed in according list
everything is saying. And then you can see
how could I ended up application how good hyperlink on how to
get the page loaded, how to get them message
displayed in index page format. In the web-based
format assessment, you are passing from the side, but on the browser side, this is what and there
are different methods, so be ready for a new session, but didn't we will be coding for HTTP server online
communication, that is HTTP Apache server, and browser communication on TCP in Windows VDB seeing
so be ready for it. Thank you. Thanks a lot.
16. Socket Session10 ProgramExecution HttpApacheServerClientCommunication Windows C++ Part1: Hi, and welcome to
this new section that is programming and
execution of a TPP. Our t-shirt would browser client communication
on the IDE, on DHCP. As in the previous session, we have seen the
understanding of the HTTP Apache server browser. Client communication may have seen what all things
are required, how the sidebar and browser
communication takes place, how the client, but when, whenever we are launching, we added typing any link
on the web browser. And the browser it can be, it can be exploded, it can be grown, it can
be Firefox, browser. I am deputation. Then this URL is sent to the sidebar in the form of the
header we have seen, we have seen the
format of the header. So please refer the
previous section if you have not gone through it, it is the understanding in detail before starting
this program execution on ID and doing this communication on the
browser and Apache server. We have seen how the client
will send a message to the sediment and don't
informal the header, then settler will respond to it. Same in dome Salk header, header and the body. Then finally we get the message where they hadn't decided, well, we'll send the message will be getting displayed on the
browser and the web page. We will be seeing this
will be executing, will be writing the program on the ID that is called block ID. Here we are using it as
it is freely available, and then we will be
executing it and you will be seeing how we are
doing the communication. Let's start. Now the program statement, which I have mentioned
now that on the browser, what we will be doing
this under browsers. Suppose you are using
a Chrome browser. You can use any browser. In our case, we'll be
using Chrome browser. And the user gives
the link like this. What is this link? User
can give any link. So by I've given this
link because I want, I want mine to take the communication in
the same host machine. Bede writing the code in
the cell in the manner undecided voters buying to the IP address of the
local host itself, of this machine itself. And it will be binding
to the same local host. And the client will be then wanted to connect
to the server. So we have to give
the same IP address. So I had wondered
who told you one to seven dot 0 dot one, which you give on
the client side. So all these understanding, writing the program
as I told you in the previous session also, it requires the knowledge
of TCP communication, which we have seen
socket programming, which we have done
for the windows. We have done set of
online communication in a previous to
previous session, we had seen how to do so if
you could written the code for the server as well as client and then
the communication. So I have old
waterfall methods are used for server-side
end product lines. I like volume. Then it needs to listen and then except under syllabus
I've seen on those. So you have gone through
all this session. You are going good sequentially. Almost decoding which
we will be doing. What does HTTP instead worth? Nine, will be using the
same coding which we have done for the TTP socket programming server
client communication. But a little modification might be a one-line modification on height of sending the message
from the server to client. As we have seen, if we have to do the communication for our, for that stock
certificates are worth nine communication and message. We should be done so it should have been
the header format. Server should be giving the response to the
client in FOMO, not as in pretext. That is only a modification to three lines of code rest older. What will be the same
for the server site, which you haven't
done further PTP, which we have seen
and executed on. So we don't need to
write that line. Ford hillary, we have to write only the server port lines
and you ingest typo, you widen on this
could own browser, this particular IP addresses, it's a loop back address. That means it is this addresses on this local
host machine itself, whatever the IP addresses there of the local host machine, it is that on the IP address and port number which
we are giving a 0 AT, we know that this is specific to HTTP will be giving the board
also for the server side, this is good line saying
wherein we will give this URL on the Chrome will
not write that line code, not required this unit to open this URL and that URL
only which are open if you want the communication
to take place on the same host machine for
this line. So this minima. This will be, and I
think to the IP address, local IP address of
the machine itself. So give this IP address itself. And this port numbers are simply the client will
connect to the server and said What about whatever
message we're sending from the service via sending
it in the SOC credit, consisting of the Haggadah as well as the body to
body will continue. The message has been
also you need to pass. And then output. That is on the phone display, you will be getting output
whatever the sockets, whatever the server
sends to the client, the message like high auto, welcome to the
socket programming whatever messages
over centralis. So starter code so that you
can isn't he understand? This is just the
program statement. What I told you. You have to
open this link on the room. This is the applica, this is the client application
that was at application. Then the request will be sent
to the server and server will respond by
sending the body. And then you will
get on the display the message which answer
was and students. In the page, it's an end also we can see
in the command wrong, like when you run cerebral code, you can see what all
client has sent to it. We have seen also that in
detail in the previous session. So let's see here then how the communication occurs between the browser,
client and Apache. So when we give this but this
link Endo Chrome browser, then that link is sent
in the form of header. I have already
discussed this message. This I saw the link
will be sent to the clients and the clients
and we're typing this link. And then client will constitute, will create a header, will be sending to the server. So it will be constructing the hidden and
then sending to the server. We have seen how when the client sends constructs they're
headed, how does it loosely? I have seen, in that
case the method is done. Then we have seen it
gives that result. We have seen, then there
is a protocol version, then that is a host. Then that is a huge region on the older format in which
a deadline sense to the server in terms of
header we have already discussed previous to this
session, please go through it. And Dani, I mentioned it, sends the message to the
seventh times I've heard it said what should respond
to this client also, in terms of header itself, I didn't body format, it's just repeated this
unimodal sideways and stimulus sense that responds to the client and the server
sends it in that line. So it should be in the
head and body format. So we have seen the server will be sending this
proof of all virgin, then the status that it
is successful or not. So status number of status
message in this map format, then this detail dates,
identify content type. So in our case it's
simply text message. If it chose the content
type is text, HTML. If it was the image, then it would give benefit
and then content land, that mean, that means
how much data is transferred from the server to client side and then
non-blank lines. And here you will be
writing the message. So let us see how to write them as h
from the server site. There have been beyond the
change which is required in addition to the board between
a scene or the TCP server. Then this is a message which we need to send from
the server to client. I'm just mentioning here in this presentation and
then rewrite the board. So then it will make you
a z to understand this revised or the little bit concepts, alcohol
communication goals. Then there is a reason
I'm just going, going through this presentation now this message,
what you will send, you just don't correct
indices are adding or you can define, you can hash define max, sum size and you can hatch to find its eyes to this number and you can read the signs here. This is just a simple Gooding
to understand the concept. And then what I'm doing, I'm initializing this
string to this frame. This is just a string
that is the message, this is Ariel characters
and I'm writing string copy and I'm
passing this string to it. So as I told you that, as we have seen in this slide, that does, I should
send in this format. So this details on me, I have filled in
the message that is protocol version than the status numbers Davis message and this date server
content and content. And so if you see this message, it is bits on the HTTP, then their version
of the protocol and the non-profit status
then okayed it as a message than the continents and then it's 47 content. That is, how much data is sent from the server to client content time that
it takes to steam. And then we add in
the body actually, then there will be a blank lines of slash and there
is a new line. And then body I'm
writing hi from tsunami. I can write anything
I'll be writing. I can write boning
socket programming, hello or whatever message
you want to censor. This is a message with students. This message will get
displayed on your page. So this is what you will be
sending from the server side. So let's begin our code. So you need to install Code Block ID is freely available and
it is an open source. You don't need to
buy the license. It's very easy to install and just go to the download site and just install it and start
programming with it. Let's begin. In my case already I'm open before menu and double-click
on the code block. You'll get this page. Let's create the project new
project console application. Click on Next, C plus plus, then the name that is here. It is. Going to give it
a sensible name, then click on Next, then finish. It will dump on the call
Hello World program for you. So let me increase the text
size so that you can see whatever you will be
typing hill just a second. Jews will be very big. Let me dive a copy
paste the code. I've already written the code. I don't want to waste
diamond typing single liner, like explain each line. So it's only the
repetitive code. Simply additional this message which I have shown in
this presentation. That's it. So let's open. I have copy pasted it. Okay. This is the whole code, so this is not new for you. You have already seen it in the valuing the
communication of TCP. Let me revise it. 12 like extra line in case of HTTP server
offline communication. What we are doing first of all, our program execution starts
from the main function. Again, the reason seeing
the lumen function is an entry point to start
execution of any program. Whatever lines of code you
write in this main function, it will be executed
line by line. So now we have to declare
these header files. In case of the Windows
operating system, it will show that we can use
the functions from this. Whenever you're calling any
function, using any function. Since I did find
you have mentioned it won't give any compiled a meadow string actually, that is this a real
book character and we have simply initialize
it with this format. I will explain you
this the same format. Yet I'm piping the messages, learning from learning
socket programming. Then. This is WSL data. So you have already
seen what is WASH. me. Revise it quickly. So this WAS data is used to initialize government
Socket Library. We have seen this WAC d tau, that is post-op all this data, which is that it is a structured crossing the structures
in second argument. So what does this structure? So first of all, what is this function,
as I told you, it is used to initialize them. And Socket Library, zipper
pulls off this WSS data in which the first argument says on what the program
wants to use, which login on women
socket library. Since the program wants to
use the version 2 we have to give in this format make one and then round
bracket two comma 0. Then this second argument,
that is Ws data, that is a structure
that is this. You have created an
object of this structure. That structure. So here
we're passing that. You are mentioning the
address on this structure, so it gets spilled
by this function. What is the purpose
of this structure? So it will say this diamond salt library will pass the critical information. No program saying how
many number of sockets can be created and other
necessary information. This is how it gets built when we call
this target function, which is used to initialize
the wind socket library. Then we have seen on this
ROSI and you need to create a socket by calling socket function three arguments
or their posts argument. This is an Dennett
interests family. It is EOQ underscored in a second is a type of the
socket type. It is a stream. We're using a reliable
socket communication and always remember
since we are doing the communication of HTTP, you should always take
place on TCP itself, that is VCB rack where
you have dimension. Do you see music
communication protocol? You have already seen in
socket to be six session. And you mentioned the stream
type and then the zeros. This is the default
communication protocol. You guys in a chaser 0. So now we have
created the socket, now it will return the
socket descriptor. So by this descriptor, we will be calling
the bind function, will be calling the
listen function, then exit function by
this descriptive since we will be binding to this
socket descriptor socket, then that piece of
code is this one. This, we have already seen
that this is a structure. Add R. So it is, it is a structure that
is here we have written, although tight, this one, this is a structure
and this is a video, a bit of a sphere
created you have, I told you we have to create
new advantageously get the socket descriptor
post by calling the socket function and
analysis on a disk news, saga, descriptive
and Nicole the exit function we have already added. And this this structure. In this structure
you'll be filling the IP address where this
Edward needs to bind to, as well as support normal, all the necessary details
you'll be giving in there. That is what you are giving IN a DVR and exclude
any unintrusive. I have explained in detail
what is the meaning of this IP address to which the server should bind to is
we have utilized to this. What is i an EdD at
underscored need can be binding to all the
network interfaces in the same host machine. So if you connect, if
you're using none, It is having
different IP address, is independent
network interface. That IP address the
server again by infill whatever you're using to
connect to him in the neck. If you are using land out, if you are using Wi-Fi, Wi-Fi and having different idea, a different network interface. Again, if you're using Wi-Fi, then it will, it can bind
to five-year dissolve. There it is. It can be buying two network
interfaces which added then, this is what we
had mentioned that then number we are
listening dub. Sideways should bind
to this port number is 0 AT for the HTTP connection. On the client side, it should be connecting to
the same port number. That is, what is buying two. So this is very much important
diabetes important number that line should be
mapping to the same one, should be connecting
to the same one. Then this structure we
have felt we are calling the function in which we are facing this socket descriptor. We are passing this address. Disruption actually
had fairly over diabetes and the port
number and the size of it. Then we had a calling
the lesson function. Now, you're listening. Listen function
again, we're passing the socket descriptor
as opposed to argument. Second argument contains
known how many number of the client connection should
be in the waiting queue. How many decided what again, process actually one
by one and Ken process once the one is completed
communication mid-month line, then it will be processing the another line to how many
number of numbers it should be there should be waiting of client connection site but accepting declining
line connection site, connecting to the client. So how many number of client requests can be there
if there are multiple lines? So if there are three lines, we want to be on,
Connect actually, so they should be in the waiting
line is being processed. So we can mention that number of nine condition that
should be innovating. You mentioned zeros since we want only one
connection after time.
17. Socket Session10 ProgramExecution HttpApacheServerClientCommunication Windows C++ Part2: Once it gets a connection
from the client side, it is listening, and then it
will accept the connection. So you are in past the
descriptor of the socket. We'll pass this structure
which is empty. This gets spilled when we
call the exit function here, the details of the client will
be there which IP address, port number and all that. This ISO for destruction,
checking this condition, whether it is successful
or not successful, then it will return on load is crypto dividend
descriptor of the socket, new descriptor of the socket. So why do descriptors
are required are to you the first
descriptor which is dead, it is required to x to listen. Actually funded independent
connection request. This will be engaged
with that of the client. And the socket is could've DO is used to send and
receive the data. So this will be engaged
in this, in this work. So therefore, this
will be different than what we are doing. Here. We had receiving the
message from deadline. So what message
here you will get simply since we will be writing, typing, or writing that, I've been a link on
the Chrome browser. As I told you what, you will be passing just
a local host port number. In that case, this message, but it'd be passed from
client to server incomes of former Soviet above
Bassanio link. So I told you that it
should be fast in terms of our header comments
from client to server, the message will be
passing handling have seen that header format
in previous sessions. It should be sending
the method and there should be U1, U2. It should be the protocol
version cost upon the method. Then it should be the URL, then the protocol
version, and the host, then the User-Agent headers. So whenever you'll be receiving that message
from the client, that message will be received in this string
that is about four and we're printing
it so you will get all the things printed
on the server side. What client sees that
is at hided format, that is about the motion on the HTTP then about the
URL, then about them. About this, about
the method possible, you will get the method,
then you will again though, URL and you'll get the HTTP version and who's the user region,
you will see that. And then, then the sight of God, which is sending the
message is this one. What does this
message we have seen here and we have
felt to this one, that is we're passing also the response from the server
in the header format, not a simple text message, not hello, hi, like that We are. You have to write in this format itself so that the message which will be sent
from the server to client should be
getting the display. Display, which will
get on the console should be the inner
web page format. So that will be a
passing the login here. Then those datas, numbers,
status, message content, and how much data has bonds
forms our deadline then than ten types into detects
SDM and the main body. This message or this react passing simple message
learning socket programming. So this should be
displayed on the browser. Once though sediment gets
connected, do it at the line. Client descending
the complication. Like client, we are
launching the URL. And then you add a list obtained from client to
server, informal ******. And then we'll also send this message and formal
credit and on the browser. Finally, you'll get the message
whatsoever since this is what the parsing thrombo yet from the server to client this message and then
we add checking it. No editor is that if it
is a message meant to 0, then we are closing the socket. So this is all coding required. What HTTP server, we don't need to do the coding or client, simply you need
to type a link on the browser that is only though or message
which didn't listen. And denominator compile
the code. And let's see. This is combined
the current file. So here you can see no mitosis present and let me just try. New ideas are present. Now you need to run this
program by clicking. Know how you want,
you have to go to. I have already told in
the earlier session, also, go to the View. And then in the loss, you have to take this box. Now when you give a bill, actually when you do build
and run, in that case, you can see here the
server is running and it allows it asks you, this is a viable whether
you want to allow Nexis? Yes. Now the server is listening
for incoming connection. Now we have to send, you
have to open the URL. You have to type a link on
the link on the browser. That will be the simple, as I told you, it will be local IP
address one to $7 dot dot one and the port number
80 retrieval type this link on the browser
that is at nine site. Then the communication
takes place to server and server will
send the message in terms of heritage
and mitigate on that browser that message
like what we should get. We should get this one that is, whatever you have
given them a message on the body site, learning
socket programming. Let's see, Let's do it. I have opened up and
I'm typing this URL. I told you we have
two cotyledons, one to 710 No.1 colon 80. This is the loopback address, same IP address of this
local host and port numbers in the serverless bind to this IP address
and port numbers. So in on the client
side we should give the same one we are giving, then just double-click on it. So here you can see
we got this message, I double-clicked on this link. I got learning
socket programming. Now what happened? I have died on the browser, Chrome browser, this
particular IP address. The port number which
decides what is binding to simply and this
message God received, whatever the client is sending
the water, do the service, and then it will,
it will convert, find itself will convert this URL before
sending to the server, will convert it to
the header format so that in the service I will
receive that message. So let's see that message. What we got here, you can see decided where I got the message from the client side in terms of header, whenever you add a new
passed here in IVF, IP address and the port number. So it got converted to the header format and it got printed on the
software side, whatever client has
descending to server. The message. Here you can see as I told you, all these things that his
client sees this method, the protocol version, then the host is this,
then user agent. So this decline descending
to the server that we are printing on
the server-side. That as you can see, we have
seen in this program itself, just as you have seen in this
program itself, has seen. That line says, actually, and the other side, what is receiving the
message and we're bringing that is year both in buffer and we are printing
it on top, unsold. So that is a reason we're
getting all this message, whatever the client is sending to the server in
terms of header. Now, the client, then the server actually once
it receives this message, then we add again this sideways, and then the server
is sending message. Once it receives message
from the client, then the server will respond
back by sending the message. And this message
we have seen here, we are passing what
we are passing this message and dumps all kind of format
in the same format. But we are writing
all these details, this Fama Titus, different photos and for the
client or the server. First, there will be the
protocol version than the state. This number is Peter's
message, content type, content length, and
all these things, then with the bank
and then the body. What message? This message what Southwest science server sends
to the client, we gotta displayed in this base. So you can see regarding
learning socket programming. So this is a two-way
communication which took place. This is how you need to run. One more thing to mention
actually, for you, if you have never Rodin the socket communication
in your single machine, same machine might be whenever you are
writing this new ADA, end up port number you
might be getting as editor. Actually this is
very much important, so please make a
new download it. You might be getting an edit actually permission
denied because there is a firewall actually wherein it won't allow you
to communicate. Can happen. It can happen. It is allowing, but
if it does not allow, you, it gives the
permission denied. Actually, in that case, you have to do some settings. I've just mentioned
you mentioned it now so that it will
be helpful for you. So don't miss this DOM, which is very much important. Might be few phases a problem, you can fix it simply. You have to just a second. In that case, you have
to open the notepad. You have to actually, it's not allowing you to
communicate actually, and that is an error actually connecting to the
local host itself. So therefore, you have
to modify the host file. That host file, you don't have the permission to
modify it as president particular location that I will let you know
now that host file, you have to add one
line that actually, so that it can
connect to the host. That host file which you will be modifying his door is
not having permission, so you just first need to open the notepad
in this manner, return of money,
you have to write, runners administrators
will ask you, where do you want to allow? Yes. Then just I will. All right. This
line actually that is one to $7 dot
one and then local. This is the format. And
I will be saving it. Here. I will be
saving it by the name as with, ST is forced. So what will be the
location of it? It will be C. Program finds list. I have to go to C Windows system Thirty-two drivers. Then EDC. This is a location vet and I
will need to save it. And then this is the, I need to save it here by
clicking on Save. I've already saved it. Actually, I don't
want to again save, so it is already see,
just click on see. Once you click on
Save, in that case, this will be aligned you to avoid dental permission
denied problem. This will allow you to fly. There won't be a
viable actually, so you can communicate
over this local host. This is only the setting
which is required. Now, back to the presentation. Now we are done
almost with this. So yes, we are done with this HTTP server
nine communication, that is HTTP Apache
server communication with that browser
outline we have seen on the idea and
here executed it. So you can see how the communication takes
place and you can see very minimum changes required
with respect to that of the TCP communication
only we have to send the message from
the server to client. In formal pedal,
we have seen how, what is the format of it
and hope you send it out. What are the session
we have seen? How when you give the URL on the browser that
is at ground Chrome, you can use any browser,
firefox, anything. Then how this client sends
the message to the server, it will be
constituting a header. We have seen that by
printing it on top. Server's identity have seen how server side code,
which will be writing. We will be sending the message from the
server to client in formal kind of you
have seen or talked to send it in either o program. And that isn't dumps off this. And then the message
which the server sends it will be displayed
on the client side. This is how the
communication takes place and we are done
with this session. Thank you. Thanks a lot.
18. Socket Session11 ProgramExecution HttpApacheServerClientCommunication Linux C: Hi, welcome to this new session. Polyphemus operating
system hadn't, we will be doing another program for having the
communication between HTTP, Apache server, as well as browser client communication
using the C language. So earlier to this session, we have done one more program
in Linux operating system. We have seen the
programming using C as well as C plus plus for me, I've done the communication for TCP and client communication. So in this session, in this session I will
be explaining you how to achieve HTTP Apache server
browsing online communication. So here what we will be doing, this same program
I have done for the Windows operating
system using C plus plus. You have gone through
that session also here, depending upon your choices, whether you are having the
operating system has windows, you can record that session and you can write the
coding for this. Should be a party several growth than avoiding
earlier session. If you are having the
Linux operating system, you can refer this session, but we'll do the same program for the Linux operating system. What happens in this edge
to give you about Di Salvo, rosa client
communication, a shuffle. The user will be giving
a link on the browser. Browser can be anything, it can be the more quiet
box it can be grown. What will happen in this case, as this browser is a
client application. So the request internally
will be going to the Apache, sort of odd, will be in
terms of the header. And then server sends a
response in terms of header. And then that response will
be there with the message, whatever the server
wants to send to the client it all that will be displayed on the
page on the browser. So we have seen, we have done that
understanding of HTTP Apache server browser in
our earlier session there, in our understanding
of this session, but in Iceland you
the concept what HTTP Apache server
browser outline how this, how would the client
will send a request to the server in terms
of parallel format. And then how In send a response
to the client in terms of her that embodies all explanation
covered in one session. That session you
can require it for this Linux operating
system also, and also for the Windows
operating system. And then I have covered
another surgeon for the Windows wherein
we have we have, we are done with the
programming and execution on the woodblock iodine wrinkles here will that do for the Linux, will do the programming
Polynices and we'll execute it. But handsets, understanding of the concepts you can report the previous session I didn't. I have covered basic
understanding of this, how Apache server and client
communicate in terms of sending the header and how it responds the side of our gifts. So you can understand
the concepts returning the earlier sessions, which are uncommon for
both Windows and Linux. Well, let's begin here. As I told you, what we
will be doing here, I will be using the buyer
quiet box as a browser. And I will be giving this link. This link, which I'll be
giving us simply, you can, you know that this
$127 dot 0 dot one, it is a loopback
address. Explained you. Loopback address means
it is referring to the IP address of the Lucas
local hoods my chain. So this is my laptop wherever I will be giving this
link in my browser. I've had every dimension, this $127 dot one, it will report to IP address of my local machine off my laptop. It simply means that, and this is the
port number 80 AT this browser means you
deserve client application. Now this line will
communicate with them. So an outlined is
sending this link to the server to server that
is now part two servers. So I have explained in that earlier session maybe never going to
explain the concepts. So I have explained how
this client will send those over in headed what all things will
represent in handy. If you have to go
through the detail, please report those section. And then the server will send
a response to the client. So simply you will
get the whatever the server sends a message
will be loaded on this. I was at Brown said that
is on the fireball. So we have also done
the programming and another session for the
Windows operating system. Now here you will
see for the Linux, this is all what we'll be doing. Simply give this link on
the application side, on the client side that
is on the browser side, use it that is a Firefox. And then internally request will be sent from client
to server in cell itself, I will give them
message in terms of displacements in dome top header format
and what body format. And that will be loaded
on your browser, whatever the server sends
hello message that will be displayed on your browser
that is on the client side, whatever message or if
the socket program, anything, whatever
message that was sent in. It will be displayed on the
page, web page Walmart. This is what we will be
doing in our program. Then here, this is just an explanation
what I have told you. In terms of high doses,
you can go through it. Then the lingual sending a formal product to the
server from the client. And in response, I will contract message and
formal credit and body. If you have to report
the proper format of the header and body referred to earlier session understanding the
concept of program. Programming for HTTP
server outline. You can just understand, go through that session to understand the concept
in more detail. Then. This is just the head, a format which is sent from
the server to browser. So this is just a format
which I have sent, which I have displayed here. The sidebar sense whatever
that line descending or you are giving a URL on the client side that is on
the ground certifiable. Then this then the
request will be sent from the client to server.
Farms are parallel. This is what the server will
send a response to decline, and this is every response. So this is the response type
of the head and body format. Here you can see I told you more disparate isn't in the
hair determined server sends to the client, wants to call the version of the protocol we are using
the HTTP then the status, whether it is successful or not, the status numbers,
status message. Then there's details,
that is date server, and then this content
types of content type. Since in our case, in our programming,
we will send, send a simple text format. We will send a simple message, will not send the image
from the server to client. In response, we are mentioning their content
type to be text HTML, lipid was an image,
then it was different. He had We will be sending simply detects as a response
from server to client. That is the reason though. This header which
will be there and be sent from the server to
client, will be endoderm. The content type will be text, HTML, and the len, whatever data bytes
those sedimentary tending to decline in its bonds that we
have to mention here. Then a blank line that is a
little bit and this body, this body, we will be sending the message from server to
client so we need strain. You can pass you. You can
understand this is water. Those have always
send to the client. And then you will
get the page loaded. Then moving to the next thing. So here, it's all here, like in the previous session on this Linux operating system. When we have done
the communication for TCP server client, what, what will be required for
HTTP server client here, if you compare with the previous session met
and we have been thumbing holiness operating
system for TCP server line. There is no much difference
in this HTTP about digital communication
because he assembly, we have added the stolons. We have to give the message. If we send a message, it should be of this type. That is, it should be containing
the Hadean Haydn body. You can see it should
contain the header. This header. This is
the diagrammatic view. Like it looks like this. The version then the
status number of status message and
all of these details, content type, content, Lin, blank line and then body. So this we have to
write in us our code. So here we will be writing only the server code
while HTTP server, we don't need to write
the client code. While doing this or programming. Client only we have to give a
link on the router debts it and on the server side
you have to write this code and we have
to send this message. And farmer, I didn't body, which I have mentioned
in this diagram. When the service, This wants to climb, it should
mean this warmer. This is just a modification. If you have to achieve this
communication Institute, so good inclined, so you have
to add this message extra. What we will do so as compare to the earlier session
for TCP server client, what do you must drink line was simply sending a
message to the server. Here, what will happen? If you compare that program with this HTTP message to the
server in terms of URL. And then that will
be internally, it will be in terms
of header format, it should have covered
in the earlier session for understanding
the concept of this. Then that server ascend
then said about available. So send a message in a video dating the message from
the client site available. Also write the message
on the socket. So this is our
modification and what messages will be of this type? That is of this format. That is HTTP protocol
version density, this number, status numbers, status message, and
then content land, how much data it is
transferring from solar took line then the
content type where there's excess GM and then body. Then you can see
slash and that is a blank line, body and body. Yes. Hi, from whatever the
message is that whatever you are writing here
will be passed to the to the client in response. So this is an extra
thing that we'll be adding for the HTTP server or client if you compare with the previous programming
pollinates wherein the FDA, PCP several nine and
unrest all the boats. Same if you compared in which we have followed
in the previous session. Now let's start
programming ugliness using the C language like me to reach through the Linux
operating system. Unix operating systems. So I hope so you out I've
had on this dominance or we are simply moving to the
code I've already written. The code is a code for
HTTP. Just a second. Let me do things with gender. This is yard board
for STDEV server. Since I told you we
have to just write the code what side-by-side, not for the client
side, client-side, we're presumably give a link. That is, as I've mentioned, you end up with is
indigent $127 dot one, and the port number,
that is a 018. It will report the
client will report to the same local host
machine which I had in the server is running and the
same port number variable. So what is mine too?
Let me open this. As I told you, what
will be the difference? If you compare, if you've seen the Linux operating system, these header files via using
model socket programming. This is a main function
that is the entry to start an execution
of your program. All the things that
are repetitive, that is, again,
are in the Linux. I told you this socket function, which we will be
calling first of all, posts and argument will be
this Internet address family. Second argument stream data
that is a type of the socket. And third one, abnegation
group alright, equals 0. What it will return? It will return the socket
handle Let us server. And here it will be of type
and began case of Linux. This is what instructor light is used to fill the details
so that server again, what IP address and port number. So we had this, our
bodies buy into it too, particularly by IP address and port number
and this structure we can feel a bit back details IP address and port number. You have fairly here
in this three lines, you can see this one. Where are you calling
mine function? You're passing this
handle of the socket that we got here and we're
parsing this structure. And then we are calling
listen, listen. I've told you this is a socket, is a handle and this 0. That means how much number of line connection should
be in the waiting queue. So we don't want
any thing to read in the reading you
0 V harm done. You can multiply depending upon your requirement and
the order number it did with reasons we are doing X GTP recommended
communication board members. We have done so as mine
to this port number. So additionally, if you
talk about as GDP by HTTP, since I have told you this
message extremity will be sending from the server side
in our earlier session. Since we have covered what
TCP server and communication, only those boards that eating
whatever the client sense. So you can do any complication that was a chant communication
tool where you can also send from the sun
was from the server side. And you can also do read and
write on the client side, rectus, depending upon
your requirement. Here, we since whatever the client sends a
message to them, I will give a response to it. And this response, it
should be in terms of this header and body. So I explained you in the presentation on so and also the details
for hybrid and mo