MCPcopy Create free account
hub / github.com/EasyIME/PIME / bind

Method bind

python/python3/tornado/tcpserver.py:212–264  ·  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()``. The ``bind()/start()`` pattern depends on
250 interfaces that have been deprecated in Python 3.10 and will be
251 removed in future versions of Python.
252 """
253 sockets = bind_sockets(
254 port,
255 address=address,
256 family=family,
257 backlog=backlog,
258 flags=flags,
259 reuse_port=reuse_port,
260 )
261 if self._started:
262 self.add_sockets(sockets)
263 else:
264 self._pending_sockets.extend(sockets)
265
266 def start(
267 self, num_processes: Optional[int] = 1, max_restarts: Optional[int] = None

Callers 15

addAlertFunction · 0.45
addAlertFunction · 0.45
bind_socketsFunction · 0.45
bind_unix_socketFunction · 0.45
_create_streamMethod · 0.45
_detect_ipv6Function · 0.45
rtFunction · 0.45
ctFunction · 0.45
ftFunction · 0.45
tFunction · 0.45

Calls 2

add_socketsMethod · 0.95
bind_socketsFunction · 0.90

Tested by

no test coverage detected