socket.create_connection

socket.create_connection(address)

  • Connect to a TCP service that is listening on address
  • This address takes the form of (host, port)
  • The functions returns a socket object
  • This function is typically used for clients creating sockets

Example of create_connection

>>> import socket
>>> addr = ('localhost', 3591)  # connect to localhost
>>> s = socket.create_connection(addr)  # on port 3591

References

Previous
Next

Basics of socket API

socket.create_server