diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-11-02 13:57:53 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-11-02 14:47:50 -0700 |
| commit | 279180c1d07fc2c4c0bfa8f5a418cb02c4b87863 (patch) | |
| tree | b451ac7f845062674d6ab45eb5d530628d3ff47c /src/nng.c | |
| parent | 9b27984d0e2da430b78a975e59f55c96de5f6056 (diff) | |
| download | nng-279180c1d07fc2c4c0bfa8f5a418cb02c4b87863.tar.gz nng-279180c1d07fc2c4c0bfa8f5a418cb02c4b87863.tar.bz2 nng-279180c1d07fc2c4c0bfa8f5a418cb02c4b87863.zip | |
NNG_OPT_RECVFD and NNG_OPT_SENDFD converted to functions.
These options are removed entirely, and their functionality is now
available via special functions, `nng_socket_get_send_poll_fd` and
`nng_socket_get_recv_poll_fd`, making these first class methods on
the socket.
This eliminates a bit of wasteful code, and provides type safety
for these methods.
Diffstat (limited to 'src/nng.c')
| -rw-r--r-- | src/nng.c | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -11,6 +11,7 @@ #include "nng/nng.h" #include "core/nng_impl.h" #include "core/platform.h" +#include "core/socket.h" // This file provides the "public" API. This is a thin wrapper around // internal API functions. We use the public prefix instead of internal, @@ -1142,6 +1143,38 @@ nng_socket_get_addr(nng_socket id, const char *n, nng_sockaddr *v) } int +nng_socket_get_recv_poll_fd(nng_socket id, int *fdp) +{ + int rv; + nni_sock *sock; + + if (((rv = nni_init()) != 0) || + ((rv = nni_sock_find(&sock, id.id)) != 0)) { + return (rv); + } + + rv = nni_sock_get_recv_fd(sock, fdp); + nni_sock_rele(sock); + return (rv); +} + +int +nng_socket_get_send_poll_fd(nng_socket id, int *fdp) +{ + int rv; + nni_sock *sock; + + if (((rv = nni_init()) != 0) || + ((rv = nni_sock_find(&sock, id.id)) != 0)) { + return (rv); + } + + rv = nni_sock_get_send_fd(sock, fdp); + nni_sock_rele(sock); + return (rv); +} + +int nng_pipe_notify(nng_socket s, nng_pipe_ev ev, nng_pipe_cb cb, void *arg) { int rv; |
