socket:


        The socket module in Python is part of the standard library, meaning it is pre-installed with Python and does not require additional installation. It provides low-level networking capabilities to create and manage network connections using sockets.

 

Key Features:

1.     Socket Creation:

·        socket.socket(family, type): Create a socket object.

o   family: Address family (e.g., socket.AF_INET for IPv4, socket.AF_INET6 for IPv6).

o   type: Socket type (e.g., socket.SOCK_STREAM for TCP, socket.SOCK_DGRAM for UDP).

2.     Socket Methods:

·        bind(address): Binds the socket to an address and port.

·        listen(backlog): Puts the socket in listening mode (server-side).

·        accept(): Accepts a connection from a client (returns connection and address).

·        connect(address): Connects to a server.

·        send(data): Sends data over a socket.

·        recv(buffer_size): Receives data from a socket.

·        close(): Closes the socket.