Sockets, hello, everyone, and welcome back to this video, and today we're going to talk about sockets
and one what actually sockets are when we're talking about network connection.
So basically socket in python.
So socket is a python term that is basically used in there as a standard interface of the transport
layer or the Tsipi or the you or the players.
So this is basically a way to transport data.
So when you run a socket in Python, it basically interacts with a Tsipi and the UDP transport layer
of types.
And also it is looking up for the DNS, which is the hostname or the IP address.
A socket is defined basically by the IP address of the machine, also on the part of which it listens.
And the protocol which uses, for example, if you have a socket, it will be connected to the IP address
of certain machine.
It will listen for certain ports to get access.
And also it will it will use certain protocol, whether TCAP or UDP.
So sockets are basically classified into stream sockets and into we can either have stream sockets or
data grum sockets depending on whether the services dissipate or Euterpe.
So if the service, for example, is Tsipi, then we have a stream socket and if the service is be to
have a diagram socket at the same time, they also classified by family.
For example, if you want to talk about the Unix sockets, which is specific to Unix, then you would
have the sockets that RF Unix.
So GSM sockets.
Then if you want to talk for sockets, depending on the networks that they are based on, then you would
say OK is not a definite file.
And finally, if you want to define sockets, the family of sockets, depending on the type of Internet
connection, then for example, we will have an ID six or eight for socket.
So for example, guys, Destra sockets here they are based on family.
OK, so these are all the female sockets.
In the same time, you can have the sockets based on socket type, for example, here, right type.
So basal socket type there will be three and so Deji rom so so stream.
This is related to the TCAP protocol while the socket teacher is related to the UDP, protocol is important
to understand.
So after we know this, let's go now to the terminal and do some operations with sockets.
So first of all, you need to install a socket package in your computer.
You can simply to pipe the install sockets.
OK, misspelled this with the sockets and you can see that requirement already satisfactorily have it
installed in my computer.
But if you don't have it, you will see this ledman.
Install it.
OK, install sockets.
Yes.
And let me install it back again.
So you see that if you don't have it installed it also.
So like this.
So it collects all the sockets and then starts the installation in.
This mission is complete.
This is one of the fastest installing packages in your computer.
So it will be quite straightforward.
So for example, if I want to assess the sockets from the terminal, you can simply write Python and
then as you can see, you getting to the Python terminal and now you can write a different python commands.
For example, if I write a print statement, for example, if I write print one, then it returns one
or print hello.
So if I print hello, the system will return.
Hello.
And this means that we are assessing the python environment in here.
We can simply import sockets or socket actually.
And for example, I would like to create a socket object for you can do the following.
You can write client socket equals socket dot socket and then the briquettes.
You can write sockets not AV underscored by net comma socket dot soc underscore stream.
OK, and if you see the presentation you can see that when you create socket.
First of all, we define the net in the middle of the socket, which in that case is a if I net and.
Also, we define the title of the circuit, which is the s t r e om, which is a TCAP protocol.
OK, so if a hit OK, you see, we're not getting any errors, which means that our circuit is created.
And for example, if you will not connect the socket to the server, we can usually do that with the
connect command.
We can Deucalion underscore socket.
So this is basically the name of our socket dot connect.
OK, dot, sorry, let's open bracket and let's write the name of the website that we want to connect
to in the web.
So I'll write your dot com comma a t.
So here we're connecting to you took dot com on the circuit edge so we connect to the web server.
So here is an area guys.
I actually put that into the apprentice's.
So let's change that.
And you can see that now our coaches accept it.
And here it says the Afnan through the tuple and now which is a tuple, which is fine.
So here now we created basically a connection to the Web server of YouTube on birthweight.
Also Littlefeather Colman's, for example, the BINDE command.
So let's create an arrow socket.
So I'll right here.
Server socket equals socket dot socket in here.
All right.
Socket dot a.f. i net Colma socket dot soc stream.
So we created the socket which is with the Tsipi protocol.
Now let's run this, OK?
And now we're going to bind the socket and now we can make this and now let's make server socket Douglaston
then.
Which means that our socket will listen for maximum ten connections.
OK, that's it.
So this is how we deal with talk of the case.
I hope this lecture was quite informative for you.
And that said, thank you very much for watching and I will see you in the next video.