NNG_CLOSE(3)

πŸ“¦
version 1.12.0 Β· 4 versions
, in ubuntu stonking

πŸ’– NNG_CLOSE(3) πŸ’–

okay bestie, welcome to the NNG Reference Manual β€” today's main character is nng_close, and honestly? she's the "okay bye, love u, don't text" of the socket world. sit down, grab a boba, let's get into it. πŸŽ€

✨ NAME ✨

nng_close β€” close socket. that's it, that's the vibe. she closes the socket. periodt. πŸ’…

🌸 SYNOPSIS 🌸

#include <nng/nng.h>

int nng_close(nng_socket s);
int nng_socket_close(nng_socket s);

πŸ¦‹ DESCRIPTION πŸ¦‹

so the nng_socket_close() function closes the socket you hand it, s. and listen β€” messages that have already been submitted for sending may be flushed or delivered, depending on the transport. so like, it's giving "maybe she'll text back, maybe she won't." πŸ™ˆ no cap, that's genuinely how it works, it's transport-dependent.

and nng_close()? she does the exact same thing β€” she's literally just the old name for this function. and bestie, not to be dramatic, but nng_close() is considered deprecated and may be removed in the next major release. so like. she's on her way out. the way that legacy code never dies though 😭

now here's the part where you gotta pay attention. any further attempts to use the socket after this call returns will result in NNG_ECLOSED. and threads that were waiting for operations on the socket when this call happened may also return with an NNG_ECLOSED result. so everyone gets the door slammed in their face, respectfully. πŸ’€

Note 🚨 closing the socket while data is in transmission will likely lead to loss of that data. there is no automatic linger or flush to ensure that the socket send buffers have completely transmitted. like, she does not wait for you. so the recommendation is: wait a brief period after calling nng_send() or similar functions, before calling this function. literally just count to three and think about your choices. πŸ‘‘

⭐ RETURN VALUES ⭐

this function returns 0 on success, and non-zero otherwise. classic. iconic. no notes. πŸ”₯

🌈 ERRORS 🌈

  • NNG_ECLOSED β€” the socket s is already closed, or was never opened in the first place. she's either gone or never existed, and either way it's not happening. πŸ’”

πŸ‘‘ SEE ALSO πŸ‘‘

nng_strerror(3), nng_options(5), nng_socket(5), nng(7)


okay that's the whole page, you ate that fr fr 🫢 NNG Reference Manual, dated 2026-06-30. go close your sockets responsibly, babe. mwah. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from