In python, we have a module named as socket which helps in networking between client and the server.
We can easily import socket module in python. We don’t need to install it from anywhere. If you are downloading it through pip install it means you are installing os from pip install.
socket module has a function known as socket(). It is used to create a socket.
a = socket.socket(socket_family, socket_type, protocol)
socket_family- This is either AF_UNIX or AF_INET.
Socket_type- This is either SOCK_STREAM or SOCK_DGRAM.
protocol- This is usually left out, defaulting to 0.
bind()– This method binds address (hostname, port number pair) to socket.
listen()– This method sets up and start TCP listener.
accept()– This passively accept TCP client connection, waiting until connection arrives.
connect()– This method actively initiates TCP server connection.
send()– This method transmits TCP message.
recv()– This method receives TCP message.
close()– This method closes socket.
These are methods in socket module in python.