| nn_term(3) |
| ========== |
| |
| NAME |
| ---- |
| nn_term - notify all sockets about process termination |
| |
| |
| SYNOPSIS |
| -------- |
| *#include <nanomsg/nn.h>* |
| |
| *void nn_term (void);* |
| |
| |
| DESCRIPTION |
| ----------- |
| To help with shutdown of multi-threaded programs nanomsg provides the |
| _nn_term()_ function which informs all the open sockets that process |
| termination is underway. |
| |
| If a socket is blocked inside a blocking function, such as |
| linknanomsg:nn_recv[3], it will be unblocked and ETERM error will be returned |
| to the user. Similarly, any subsequent attempt to invoke a socket function other |
| than linknanomsg:nn_close[3] after _nn_term()_ was called will result |
| in ETERM error. |
| |
| If waiting for _NN_SNDFD_ or _NN_RCVFD_ using a polling function, such as |
| _poll()_ or _select()_, the call will unblock with both _NN_SNDFD_ and |
| _NN_RCVFD_ signaled. |
| |
| The _nn_term()_ function itself is non-blocking. |
| |
| |
| EXAMPLE |
| ------- |
| |
| ---- |
| s = nn_socket (AF_SP, NN_PAIR); |
| nn_term (); |
| rc = nn_send (s, "ABC", 3, 0); |
| assert (rc == -1 && errno == ETERM); |
| ---- |
| |
| |
| SEE ALSO |
| -------- |
| linknanomsg:nn_close[3] |
| linknanomsg:nn_send[3] |
| linknanomsg:nn_recv[3] |
| linknanomsg:nn_getsockopt[3] |
| linknanomsg:nanomsg[7] |
| |
| |
| AUTHORS |
| ------- |
| Martin Sustrik <sustrik@250bpm.com> |
| |