nn_term.adoc 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. nn_term(3)
  2. ==========
  3. NAME
  4. ----
  5. nn_term - notify all sockets about process termination
  6. SYNOPSIS
  7. --------
  8. *#include <nanomsg/nn.h>*
  9. *void nn_term (void);*
  10. DESCRIPTION
  11. -----------
  12. To help with shutdown of multi-threaded programs nanomsg provides the
  13. _nn_term()_ function which closes all open sockets, and releases all
  14. related resources.
  15. If a socket is blocked inside a blocking function, such as
  16. <<nn_recv#,nn_recv(3)>>, it will be unblocked and EBADF error will be returned
  17. to the user. Subsequent calls on such sockets will also return EBADF.
  18. Attempting to open a new socket with <<nn_socket#,nn_socket(3)>> will
  19. result in an ETERM error.
  20. If waiting for _NN_SNDFD_ or _NN_RCVFD_ using a polling function, such as
  21. _poll()_ or _select()_, the call will unblock with both _NN_SNDFD_ and
  22. _NN_RCVFD_ signaled.
  23. EXAMPLE
  24. -------
  25. ----
  26. s = nn_socket (AF_SP, NN_PAIR);
  27. nn_term ();
  28. rc = nn_send (s, "ABC", 3, 0);
  29. assert (rc == -1 && errno == EBADF);
  30. ----
  31. SEE ALSO
  32. --------
  33. <<nn_close#,nn_close(3)>>
  34. <<nn_send#,nn_send(3)>>
  35. <<nn_socket#,nn_socket(3)>>
  36. <<nn_recv#,nn_recv(3)>>
  37. <<nanomsg#,nanomsg(7)>>
  38. AUTHORS
  39. -------
  40. link:mailto:sustrik@250bpm.com[Martin Sustrik]
  41. link:mailto:garrett@damore.org[Garrett D'Amore]