MCPcopy Index your code
hub / github.com/python/cpython / create_server

Method create_server

Lib/asyncio/base_events.py:1534–1677  ·  view source on GitHub ↗

Create a TCP server. The host parameter can be a string, in that case the TCP server is bound to host and port. The host parameter can also be a sequence of strings and in that case the TCP server is bound to all hosts of the sequence. If a host appears mult

(
            self, protocol_factory, host=None, port=None,
            *,
            family=socket.AF_UNSPEC,
            flags=socket.AI_PASSIVE,
            sock=None,
            backlog=100,
            ssl=None,
            reuse_address=None,
            reuse_port=None,
            keep_alive=None,
            ssl_handshake_timeout=None,
            ssl_shutdown_timeout=None,
            start_serving=True)

Source from the content-addressed store, hash-verified

1532 return infos
1533
1534 async def create_server(
1535 self, protocol_factory, host=None, port=None,
1536 *,
1537 family=socket.AF_UNSPEC,
1538 flags=socket.AI_PASSIVE,
1539 sock=None,
1540 backlog=100,
1541 ssl=None,
1542 reuse_address=None,
1543 reuse_port=None,
1544 keep_alive=None,
1545 ssl_handshake_timeout=None,
1546 ssl_shutdown_timeout=None,
1547 start_serving=True):
1548 """Create a TCP server.
1549
1550 The host parameter can be a string, in that case the TCP server is
1551 bound to host and port.
1552
1553 The host parameter can also be a sequence of strings and in that case
1554 the TCP server is bound to all hosts of the sequence. If a host
1555 appears multiple times (possibly indirectly e.g. when hostnames
1556 resolve to the same IP address), the server is only bound once to that
1557 host.
1558
1559 Return a Server object which can be used to stop the service.
1560
1561 This method is a coroutine.
1562 """
1563 if isinstance(ssl, bool):
1564 raise TypeError('ssl argument must be an SSLContext or None')
1565
1566 if ssl_handshake_timeout is not None and ssl is None:
1567 raise ValueError(
1568 'ssl_handshake_timeout is only meaningful with ssl')
1569
1570 if ssl_shutdown_timeout is not None and ssl is None:
1571 raise ValueError(
1572 'ssl_shutdown_timeout is only meaningful with ssl')
1573
1574 if sock is not None:
1575 _check_ssl_socket(sock)
1576
1577 if host is not None or port is not None:
1578 if sock is not None:
1579 raise ValueError(
1580 'host/port and sock can not be specified at the same time')
1581
1582 if reuse_address is None:
1583 reuse_address = os.name == "posix" and sys.platform != "cygwin"
1584 sockets = []
1585 if host == '':
1586 hosts = [None]
1587 elif (isinstance(host, str) or
1588 not isinstance(host, collections.abc.Iterable)):
1589 hosts = [host]
1590 else:
1591 hosts = host

Callers

nothing calls this directly

Calls 15

_start_servingMethod · 0.95
_check_ssl_socketFunction · 0.85
setFunction · 0.85
_set_reuseportFunction · 0.85
strFunction · 0.85
socketMethod · 0.80
ServerClass · 0.70
gatherMethod · 0.45
warningMethod · 0.45
appendMethod · 0.45
setsockoptMethod · 0.45

Tested by

no test coverage detected