From 279180c1d07fc2c4c0bfa8f5a418cb02c4b87863 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sat, 2 Nov 2024 13:57:53 -0700 Subject: 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. --- src/nng.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/nng.c') diff --git a/src/nng.c b/src/nng.c index e9574626..08c70857 100644 --- a/src/nng.c +++ b/src/nng.c @@ -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, @@ -1141,6 +1142,38 @@ nng_socket_get_addr(nng_socket id, const char *n, nng_sockaddr *v) return (socket_get(id, n, v, NULL, NNI_TYPE_SOCKADDR)); } +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) { -- cgit v1.2.3-70-g09d2