ZMQ_DISCONNECT(3)
π ZMQ_DISCONNECT(3) π
okay bestie, welcome to the 0MQ Manual β this one's all about β¨ zmq_disconnect β¨, aka the "we're breaking up (politely)" function. no cap.
πΈ NAME πΈ
zmq_disconnect β disconnect a socket from an endpoint π¦
β¨ SYNOPSIS β¨
int zmq_disconnect (void *socket, const char *endpoint);
π DESCRIPTION π
so like. the zmq_disconnect() function shall disconnect a socket β the one you passed as the socket argument β from the endpoint you passed as the endpoint argument. that's it, that's the vibe. π
lowkey important: the actual disconnect system call might happen at a later time. not me being fashionably late to the syscall π
once you disconnect, a few things go down:
- the socket will also stop receiving messages originating from this endpoint, periodt. π«π₯
- the socket will no longer be able to queue outgoing messages to this endpoint.
- the outgoing message queue associated with the endpoint gets discarded. bye bye π
- BUT β and this is the iconic plot twist β if the socket's linger period is non-zero,
libzmqwill still attempt to transmit these discarded messages, until the linger period expires. she's persistent, we love that for her. π
the endpoint argument is as described in zmq_connect(3) π«Ά
β οΈ Note β οΈ the default setting ofZMQ_LINGERdoes not discard unsent messages β this behaviour may cause the application to block when callingzmq_ctx_term(). for the details, go readzmq_setsockopt(3)andzmq_ctx_term(3). iykyk π
π RETURN VALUE π
zmq_disconnect() shall return zero if successful β slay. β
otherwise it shall return -1 and set errno to one of the values defined below. not slay. π
π ERRORS π
EINVALβ the endpoint supplied is invalid. π«ETERMβ the 0MQ context associated with the specified socket was terminated. rip πͺ¦ENOTSOCKβ the provided socket was invalid. bestie that's not a socket πENOENTβ the provided endpoint is not in use by the socket. who? never met her π
π§ EXAMPLE π§
connecting a subscriber socket to an in-process and a TCP transport:
/* Create a ZMQ_SUB socket */
void *socket = zmq_socket (context, ZMQ_SUB);
assert (socket);
/* Connect it to the host server001, port 5555 using a TCP transport */
rc = zmq_connect (socket, "tcp://server001:5555");
assert (rc == 0);
/* Disconnect from the previously connected endpoint */
rc = zmq_disconnect (socket, "tcp://server001:5555");
assert (rc == 0);
look at that assert after every call. that's main character energy. protect your rc, bestie. π
π¦ SEE ALSO π¦
π AUTHORS π
this page was written by the 0MQ community. to make a change please read the 0MQ Contribution Policy at http://www.zeromq.org/docs:contributing. π
and that's the whole page, fr fr. this was ZMQ_DISCONNECT(3) from the 0MQ 4.3.5 era, dated 10/09/2023 β literally iconic, no notes. go forth and disconnect responsibly, bestie π«Άπβ¨
π¦ where this page comes from
- epel 10: zeromq 4.3.5-18.el10_0 Β· MPL-2.0 AND BSD-3-Clause AND MIT
- fedora 43: zeromq 4.3.5-22.fc43 Β· MPL-2.0 AND BSD-3-Clause AND MIT
- fedora 43: zeromq 4.3.5-22.fc43 Β· MPL-2.0 AND BSD-3-Clause AND MIT
- fedora 44: zeromq 4.3.5-22.fc43 Β· MPL-2.0 AND BSD-3-Clause AND MIT
- fedora 44: zeromq 4.3.5-22.fc43 Β· MPL-2.0 AND BSD-3-Clause AND MIT
- opensuse-leap 16.0: zeromq-devel 4.3.5-160000.2.2 Β· MPL-2.0
- opensuse-leap 16.0: zeromq-devel 4.3.5-160000.2.2 Β· MPL-2.0
- opensuse-leap 16.0: zeromq-devel 4.3.5-160000.2.2 Β· MPL-2.0
- opensuse-leap 16.0: zeromq-devel 4.3.5-160000.2.2 Β· MPL-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms