-2

I saw an example of using the socket module in python and I saw a line of code like this:

s.listen(5)

What does the 5 mean? Google doesn’t have an answer.

FossilMilk
  • 9
  • 1
  • 2
  • 2
    https://docs.python.org/3/library/socket.html#socket.socket.listen – Jon Clements Apr 28 '22 at 17:20
  • 1
    Google doesn't have an answer? https://man7.org/linux/man-pages/man2/listen.2.html That says your server can accept no more than 5 connections at a time. – Tim Roberts Apr 28 '22 at 17:20
  • 6
    Don’t ask Google. Ask the documentation. – deceze Apr 28 '22 at 17:20
  • https://docs.python.org/3/howto/sockets.html is a good read if you're going to be doing something with sockets – Jon Clements Apr 28 '22 at 17:21
  • [google "argument to socket listen"](https://www.google.com/search?q=argument+to+socket+listen&oq=argument+to+socket+listen&aqs=chrome..69i57j33i160j33i22i29i30.6910j1j2&sourceid=chrome&ie=UTF-8) does have the answer – Barmar Apr 28 '22 at 17:22

1 Answers1

-1

listen() marks the socket referred to by sockfd as a passive socket, that is, as a socket that will be used to accept incoming connection requests using accept(2)

  • If you want to answer the question that was asked, you should add to your answer an explanation of what the argument passed to listen() does. – Jeremy Friesner Apr 28 '22 at 17:37