Socket module in Python

To create a socket, the socket.socket() constructor is used, which can take the family, type, and protocol as optional parameters. By default, the AF_INET family and the SOCK_STREAM type are used.

The general syntax is socket.socket(socket_family, socket_type, protocol=0), where the parameters are as follows:

  • 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
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset