 Hi everyone again welcome to this lecture of the LPS course programming class we will be looking at the tickle programming we will continue with the tickle programming today I will go through some of the some more advanced topics on the tickle before that I just wanted to mention a quick recap of what we covered in the last class the last lecture we continued our string substitution I mean the strings and list from various data structures we started looking at the procedures and as you know the procedures have like three main sections actually if you are counting the number of arguments there are five and then the first it starts with the keyword proc then followed by the name of the procedure then some set of params then it goes into a body essentially actually the four the four main parts essentially and then when you and most of the the tickle scripts are written with these procedures so it is basically starts it starts with proc and then your procedure name followed by params followed by the body as you know like I mean you need a blank space here this you have you can put the parenthesis and this is again balances I mean sorry the braces the double braces essentially so and then the return value typically is you can specify it as return at the end of the procedure or if you do not have anything written the last evaluated function that output will become the output of the proc and then we also looked at how do we specify the params are the arguments what if we want to do it with we have like many number of params a variable list variable length parameters then we can use the keyword ARGS which kind of it stores in the list of all the values so every time you call the pro the proc the number of arguments can be different and it will take away take it as this we also looked at some of the scope related issues which is by when you use the variable how do we determine the scope which is inside the proc and if you are setting it outside like that x 10 then now if you want the x to be used inside the proc what will it be so to get this x into the proc we use this command called GLOB which is essentially the I mean actually the GLOB global the global command actually gets this value and then global x basically confirms that actually the x that is defined here can that value can be used inside the procedure as well again point note is the global x command itself is not setting any value to the value a to the variable x that needs to be set outside it is only make sure that whatever is set outside can be read inside and then we have like a couple of other things basically want to communicate a particular value of the variable that means that say like you want to edit this one basically without specifying this and then say like inside the proc you are saying like set x 10 and then this x wants to be visible outside the proc the way to communicate is through in using the upper and then so you can specify saying that my upper x is actually or $x is whichever value in the previous one say here it is actually why then so this 10 whatever the changes that brought back to the why after executing the procedure same thing like I mean we also have like up the level yeah so the up level we saw that basically it is to communicate a script back to the top level that that is where we use up level so we saw that and then we also saw some of the the main rules of tickle I mentioned like six rules six rules of tickle I hope you remember all those things essentially I am not going to repeat but just in case like I mean so the main two things are the variable substitution this is through $ and then the command substitution this is using the square brackets so these are two main rules and then other than that the rule about the interpreter versus the parser is important interpreter takes in a command and then basically splits it into words based on blank space as you know like the blank space is the delimiter for words inside the command and then this is sent to the parser the parser parses this command and it knows like how many variables need to be there for the given command and then it processes the starting and this can be like recursively called meaning like the command again once again it sends the thing if it has another command substitution maybe it will send it back to the interpreter and then it can it again like goes through so the recursion is possible in the commands so the keeping is okay so then the blank space and then the for separating out the commands we need to use the seven column or a new line so these are all the these are variable various rules that we saw and then the remaining rules are pretty much exceptions to these rules meaning like if you want to group the soft grouping in the the hard grouping the hard grouping with the braces the braces and then the soft grouping is through the codes and the difference between this and this is any kind of special characters can substitute it inside this whereas here it is not substituted and then we just keep saying so we went through all these different things basically in the last lecture I hope it is a it is a right now like I mean you are much more capable of using tickle and then probably like I mean you can use so tickle for programming your various assignments and a couple of other things also we mentioned was so how to actually use some of these commands to provide the documentation or help commands things like that within the proc itself and then also like I mean we can we can so there are some guidelines for making sure that the programs are correct from the head go we talked about all those things so today we will be talking about the TCP port sockets basically like how to set sockets with tickle and then how do we communicate between various servers using tickle and then finally I have one example that we will kind of we will go through it there are some concepts that we learned in that example we will see how those concepts are these rules the six rules that I mentioned now also like explained there so we will see like I mean how those things play out and how does it work how does tickle work in a big command so let us look at first of all some of the networking items so we saw in the very first lectures as to how the old networking works we know that the late there are layers of a fraction we defined the seven layers for defining the network in a PCP scenario it could be just five layers but essentially and then the lowest layer is the physical layer which is essentially it is a wire that communicates between I mean our sense the real packets or real data between the two computers and then we also saw that how the internet is using this TCP IP protocol this is shown here and then we saw in fact even the IP addresses basically like the IP addresses are the long values essentially it is like a 32 bit number divided into like various octals essentially so and then we also knew that actually how to code all these values what is a subnet versus the main network address and then there are also like port numbers in the networking usually we use the port number 80 for any of the the web traffic and then 25 is used for the mail traffic so these are all like physical ports opening in the various servers and then we can use this to actually build pipes through which we can communicate and traditionally these pipes are known as so the sockets are built on top of TCP IP we actually saw some of the sockets earlier as to how we can use Unix five system across so the sockets essentially the main function of the puppet is it listens on a port for any connections and then it contacting the port on some machine for service so those are the two things that the sockets can do one is if it is in the current machine it listens for the port for any any connections that is being established and if you are communicating to another machine where your machine is more like a client and the other machine is a service then it basically it pulls that machine the once the socket is established it pulls that machine for service so these are the two main things that you may want to look into and then the tickle already has a built-in simplified socket network so let us look at how tickle works in this scenario so tickle has a built-in procedure called the socket and which creates this retro connection here there is a quick example set f socket and then the address and then the port number so now tell me like I mean how many arguments the socket command have actually there are only two here which is one is the IP address and then the other one is port number actually there is also an there is an additional argument that you can specify which is accept essentially and then when you specify the accept actually we turn a particular machine into a server and so essentially like I mean this means that actually is a server socket so your machine is now going to act like a server and it will it will service the request from other clients so let us continue with this one so the other one is like the f configure f configure whatever this socket that we got and then basically like we put some buffering on it and then the buffering is per line so every line the first line when you get it like I mean the person is called to store as a buffer and then the subsequent lines basically the previous line is stored in the buffer line and then basically we just use get and then basically we just read the socket and then write outside into this so now if you if you run this code essentially like I mean this load the HMO from stunts homepage anyway the server the socket is basically like socket minus server offset and then which port number that you want to open this socket on which you can specify the safety again we talked about this in the unit lecture the entire network just looks like a large file so that is why you can actually work these kinds of things so in order to execute certain processes we can have like two things one is we can use an exec command which is shown here and then we can also use ampersand so here we are starting emacs they basically setting the favorable editor to emacs and then executing the favorite editor with ampersand so this actually opens up a new window with a new emacs window and it won't obstruct the main process that is already working out and then the file name expansion itself like I mean we don't have to do it we can use the block command to do it so here a quick example is from LS glob start or C that gives you all the C programs essentially and then if you want to open pipes