MCPcopy
hub / github.com/zeromq/pyzmq / bind

Method bind

zmq/sugar/socket.py:291–324  ·  view source on GitHub ↗

s.bind(addr) Bind the socket to an address. This causes the socket to listen on a network port. Sockets on the other side of this connection will use ``Socket.connect(addr)`` to connect to this socket. Returns a context manager which will call unbind on exi

(self: _SocketType, addr: str)

Source from the content-addressed store, hash-verified

289 return _SocketContext(self, 'bind', addr)
290
291 def bind(self: _SocketType, addr: str) -> _SocketContext[_SocketType]:
292 """s.bind(addr)
293
294 Bind the socket to an address.
295
296 This causes the socket to listen on a network port. Sockets on the
297 other side of this connection will use ``Socket.connect(addr)`` to
298 connect to this socket.
299
300 Returns a context manager which will call unbind on exit.
301
302 .. versionadded:: 20.0
303 Can be used as a context manager.
304
305 .. versionadded:: 26.0
306 binding to port 0 can be used as a context manager
307 for binding to a random port.
308 The URL can be retrieved as `socket.last_endpoint`.
309
310 Parameters
311 ----------
312 addr : str
313 The address string. This has the form 'protocol://interface:port',
314 for example 'tcp://127.0.0.1:5555'. Protocols supported include
315 tcp, udp, pgm, epgm, inproc and ipc. If the address is unicode, it is
316 encoded to utf-8 first.
317
318 """
319 try:
320 super().bind(addr)
321 except ZMQError as e:
322 e.strerror += f" (addr={addr!r})"
323 raise
324 return self._bind_cm(addr)
325
326 def connect(self: _SocketType, addr: str) -> _SocketContext[_SocketType]:
327 """s.connect(addr)

Callers 15

bind_to_random_portMethod · 0.95
runMethod · 0.45
_setup_socketsMethod · 0.45
_setup_socketsMethod · 0.45
_setup_socketsMethod · 0.45
startMethod · 0.45
startMethod · 0.45
__init__Method · 0.45
select_random_portsFunction · 0.45
latency_echoFunction · 0.45
thr_sinkFunction · 0.45
test_socket.pyFile · 0.45

Calls 1

_bind_cmMethod · 0.95

Tested by 15

mainFunction · 0.36
testMethod · 0.36
test_context_managerMethod · 0.36
test_trackerMethod · 0.36
test_shadowMethod · 0.36
test_shadow_pyczmqMethod · 0.36
test_root_topicMethod · 0.36