Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Doc/library/socket.rst
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ The following functions all create :ref:`socket objects <socket-objects>`.
.. versionchanged:: 3.2
*source_address* was added.

.. function:: create_server(address, *, family=AF_INET, backlog=0, reuse_port=False, dualstack_ipv6=False)
.. function:: create_server(address, *, family=AF_INET, backlog=None, reuse_port=False, dualstack_ipv6=False)

Convenience function which creates a TCP socket bound to *address* (a 2-tuple
``(host, port)``) and return the socket object.
Expand Down
7 changes: 5 additions & 2 deletions Lib/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ def has_dualstack_ipv6():
return False


def create_server(address, *, family=AF_INET, backlog=0, reuse_port=False,
def create_server(address, *, family=AF_INET, backlog=None, reuse_port=False,
dualstack_ipv6=False):
"""Convenience function which creates a SOCK_STREAM type socket
bound to *address* (a 2-tuple (host, port)) and return the socket
Expand Down Expand Up @@ -804,7 +804,10 @@ def create_server(address, *, family=AF_INET, backlog=0, reuse_port=False,
msg = '%s (while attempting to bind on address %r)' % \
(err.strerror, address)
raise error(err.errno, msg) from None
sock.listen(backlog)
if backlog is None:
sock.listen()
else:
sock.listen(backlog)
return sock
except error:
sock.close()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Set backlog=None as the default for socket.create_server.