ZMQ_CLOSE(3)
π ZMQ_CLOSE β bestie, it's time to let the socket go π
okay so this is the zmq_close(3) page from the 0MQ manual, and it's genuinely so important, like the main character of cleanup functions. π«Ά
β¨ NAME β¨
zmq_close β close a 0MQ socket, bestie. that's it. that's the whole job. πΈ
π¦ SYNOPSIS π¦
int zmq_close (void *socket);
π DESCRIPTION π
The zmq_close() function shall destroy the socket referenced by the socket argument. gone. deleted. no more socket for you. π
Any outstanding messages that were physically received from the network but haven't been received by your app yet with zmq_recv() shall be discarded. like, they're just gone, poof, no cap. π
Now the messy part β what happens to messages you sent with zmq_send() that haven't been physically transferred to the network yet? That depends entirely on the value of the ZMQ_LINGER socket option for that specific socket. so it's giving "it depends", which is so real of it. β¨
zmq_close() must be called exactly once for each socket. one socket, one close. the way that it has to be exactly once is so serious.
- if you never call it?
zmq_ctx_term()will block forever. like forever forever. that's not a vibe. π¨ - if you call it multiple times for the same socket, or if socket doesn't actually point to a socket? the behaviour is undefined. we don't do that here, bestie. π
Note π β the default setting ofZMQ_LINGERdoes not discard unsent messages. this behaviour may cause your application to block when callingzmq_ctx_term(). for the full tea, go readzmq_setsockopt(3)andzmq_ctx_term(3).
Note β β this API will complete asynchronously, so not everything will be deallocated after it returns. lowkey important! see above for all the details about linger. π
π RETURN VALUE π
The zmq_close() function shall return zero if successful. iconic. flawless. π
Otherwise it shall return -1 and set errno to one of the values listed below. so if you see a -1, go check errno, fr fr.
π₯ ERRORS π₯
ENOTSOCKβ the provided socket wasNULL. yeah, you passed it nothing. it's giving empty-handed. π
π 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, bestie!! this was 0MQ 4.3.5, dated 10/09/2023, and it's the ZMQ_CLOSE(3) manual page β now go close your sockets exactly once and slay π
β¨π
π¦ 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