socket.listen

socket.listen(backlog)

  • This function starts listening for incoming connections
  • Typically, this refers to the server socket
  • The backlog represents a maximum number of pending connections the operating system should queue before connections are refused
  • The backlog value should be between 151-5

Example of listen

>>> import socket
>>> sock = socket(AF_INET, SOCK_STREAM)
>>> serv_addr = ('', 25000)  # server socket binds...
>>> sock.bind(serv_address)  # ...to port 25000
>>> sock.listen(5)  # only allow 5 client connections

References

Previous
Next

socket.getsockopt

socket.makefile