NN_CLOSE(3)

πŸ“¦
version 1.2.2 Β· 5 versions
, in fedora 44

πŸ’– NN_CLOSE β€” close an SP socket πŸ’–

okay bestie, welcome to nn_close(3) from the nanomsg girlies (that's the manual page for nn_close, section 3, iykyk) πŸŽ€


✨ NAME ✨

nn_close β€” close an SP socket 🫢


✨ SYNOPSIS ✨

#include <nanomsg/nn.h>

int nn_close (int s);

like. that's it. one int in, one int out. iconic honestly πŸ’…


✨ DESCRIPTION ✨

So nn_close closes the socket s. Periodt.

But wait, there's lore 🧚 β€” any buffered inbound messages that the application hasn't received yet? yeah, those get discarded. gone. not coming back. they're in the void now πŸ’€

And for the outbound side: the library is gonna try its absolute best to deliver any outstanding outbound messages, and it'll do that for however long the NN_LINGER socket option tells it to. lowkey generous of it ngl.

🌸 heads up: while it's doing all that lingering, the call will block. so don't be surprised if your little nn_close hangs around for a bit. it's not being rude, it's just finishing its business ✨

✨ RETURN VALUE ✨

  • if the function succeeds β†’ 0 comes back, slay πŸŽ‰
  • otherwise β†’ -1 comes back and errno gets set to one of the values listed down below πŸ‘‡

✨ ERRORS ✨

  • EBADF β€” the socket you handed over is invalid. like, not a real socket. bestie. what is that πŸ™ˆ
  • EINTR β€” the operation got interrupted by a signal 😭 and lowkey important: the socket is not fully closed yet. you can re-start the operation by calling nn_close() again 🫢

✨ EXAMPLE ✨

int s = nn_socket (AF_SP, NN_PUB);
assert (s >= 0);
int rc = nn_close (s);
assert (rc == 0);

make a socket, assert it's chill, close it, assert the close was chill. main character energy, no notes πŸ‘‘


✨ SEE ALSO ✨

nn_socket(3) nn_setsockopt(3) nanomsg(7)

go read those too, they're all part of the same friend group 🌈


✨ AUTHORS ✨

Martin Sustrik <sustrik@250bpm.com> β€” ty for your service king πŸ«‘πŸ’œ


okay that's the whole page bestie, you're officially a nn_close expert, no cap. this was page NN_CLOSE(3) from nanomsg version 1.2.2, dated 2026-01-16 β€” mwah, go close some sockets responsibly πŸ’…βœ¨πŸŒΈ

πŸ“¦ where this page comes from