MCPcopy
hub / github.com/tornadoweb/tornado / bind

Method bind

tornado/tcpserver.py:212–262  ·  view source on GitHub ↗

Binds this server to the given port on the given address. To start the server, call `start`. If you want to run this server in a single process, you can call `listen` as a shortcut to the sequence of `bind` and `start` calls. Address may be either an IP address or h

(
        self,
        port: int,
        address: Optional[str] = None,
        family: socket.AddressFamily = socket.AF_UNSPEC,
        backlog: int = _DEFAULT_BACKLOG,
        flags: Optional[int] = None,
        reuse_port: bool = False,
    )

Source from the content-addressed store, hash-verified

210 self.add_sockets([socket])
211
212 def bind(
213 self,
214 port: int,
215 address: Optional[str] = None,
216 family: socket.AddressFamily = socket.AF_UNSPEC,
217 backlog: int = _DEFAULT_BACKLOG,
218 flags: Optional[int] = None,
219 reuse_port: bool = False,
220 ) -> None:
221 """Binds this server to the given port on the given address.
222
223 To start the server, call `start`. If you want to run this server in a
224 single process, you can call `listen` as a shortcut to the sequence of
225 `bind` and `start` calls.
226
227 Address may be either an IP address or hostname. If it's a hostname,
228 the server will listen on all IP addresses associated with the name.
229 Address may be an empty string or None to listen on all available
230 interfaces. Family may be set to either `socket.AF_INET` or
231 `socket.AF_INET6` to restrict to IPv4 or IPv6 addresses, otherwise both
232 will be used if available.
233
234 The ``backlog`` argument has the same meaning as for `socket.listen
235 <socket.socket.listen>`. The ``reuse_port`` argument has the same
236 meaning as for `.bind_sockets`.
237
238 This method may be called multiple times prior to `start` to listen on
239 multiple ports or interfaces.
240
241 .. versionchanged:: 4.4
242 Added the ``reuse_port`` argument.
243
244 .. versionchanged:: 6.2
245 Added the ``flags`` argument to match `.bind_sockets`.
246
247 .. deprecated:: 6.2
248 Use either ``listen()`` or ``add_sockets()`` instead of ``bind()``
249 and ``start()``.
250 """
251 sockets = bind_sockets(
252 port,
253 address=address,
254 family=family,
255 backlog=backlog,
256 flags=flags,
257 reuse_port=reuse_port,
258 )
259 if self._started:
260 self.add_sockets(sockets)
261 else:
262 self._pending_sockets.extend(sockets)
263
264 def start(
265 self, num_processes: Optional[int] = 1, max_restarts: Optional[int] = None

Callers 4

bind_socketsFunction · 0.80
bind_unix_socketFunction · 0.80
_create_streamMethod · 0.80
_detect_ipv6Function · 0.80

Calls 2

add_socketsMethod · 0.95
bind_socketsFunction · 0.90

Tested by

no test coverage detected