NN_SHUTDOWN(3)

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

πŸ’… nn_shutdown(3) β€” the nanomsg girlie's guide to yeeting an endpoint

okay so bestie, welcome to the nanomsg manual, version 1.2.2, and today's main character is nn_shutdown(3) πŸŽ€


✨ NAME ✨

nn_shutdown β€” remove an endpoint from a socket πŸ¦‹

like, un-invite it from the party. it's giving "you're not on the guest list anymore" but politely, with lingering.


✨ SYNOPSIS ✨

#include <nanomsg/nn.h>

int nn_shutdown (int s, int how);

yes the param is literally called how and no, it's not a question about your feelings, we'll get there πŸ’€


✨ DESCRIPTION ✨

so nn_shutdown() removes an endpoint from socket s. the how parameter is the ID of the endpoint you want to remove β€” specifically, the ID that a previous call to nn_bind(3) or nn_connect(3) handed back to you. you do NOT make up that number yourself, okay? it's a returned ID, treat it with respect πŸ‘‘

now here's the part where it gets lowkey emotional: the nn_shutdown() call itself returns immediately β€” it does not sit around waiting. BUT. the library will still try to deliver any outstanding outbound messages to that endpoint for however long the NN_LINGER socket option says. so it's not ghosting the endpoint, it's more like a slow goodbye at the door while the messages get their shoes on 🫢


✨ RETURN VALUE ✨

  • if the function succeeds β†’ 0 is returned. slay ✨
  • otherwise β†’ -1 is returned, and errno gets set to one of the values listed below. not slay 😭

✨ ERRORS ✨

  • EBADF β€” the socket you provided is invalid. bestie that's not a socket, that's a vibe πŸ’€
  • EINVAL β€” the how parameter doesn't correspond to an active endpoint. like calling a number that was never assigned to anyone πŸ™ˆ
  • EINTR β€” the operation was interrupted by a signal. important: the endpoint is not fully closed yet, and the operation can be re-started by calling nn_shutdown() again. so don't panic, just run it back πŸ”
  • ETERM β€” the library is terminating. the whole thing is packing up, it's over, we're done here 🧚

✨ EXAMPLE ✨

s = nn_socket (AF_SP, NN_PUB);
eid = nn_bind (s, "inproc://test");
nn_shutdown (s, eid);

see? socket, bind, get the eid, then shut that endpoint down. three lines, zero drama, absolutely ate πŸ’…


✨ SEE ALSO ✨

nn_socket(3) nn_bind(3) nn_connect(3) nanomsg(7)

the friend group. go read them too, iykyk πŸ’–


✨ AUTHORS ✨

Martin Sustrik <sustrik@250bpm.com> β€” the icon, the legend, the moment πŸ‘‘


and that's the whole page, bestie!! this manual dropped on 2026-01-16 and it's part of nanomsg version 1.2.2 β€” now go forth and shut those endpoints down with main character energy πŸŒˆβœ¨πŸ’–

πŸ“¦ where this page comes from