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. --- include/nng/nng.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/nng/nng.h b/include/nng/nng.h index fff3db37..11729e28 100644 --- a/include/nng/nng.h +++ b/include/nng/nng.h @@ -255,6 +255,18 @@ NNG_DECL int nng_socket_get_ptr(nng_socket, const char *, void **); NNG_DECL int nng_socket_get_ms(nng_socket, const char *, nng_duration *); NNG_DECL int nng_socket_get_addr(nng_socket, const char *, nng_sockaddr *); +// These functions are used to obtain a file descriptor that will poll +// as readable if the socket can receive or send. Applications must never +// read or write to the file descriptor directly, but simply check it +// with poll, epoll, kqueue, or similar functions. This is intended to +// aid in integration NNG with external event loops based on polling I/O. +// Note that using these functions will force NNG to make extra system calls, +// and thus impact performance. The file descriptor pollability is +// level-triggered. These file descriptors will be closed when the socket +// is closed. +NNG_DECL int nng_socket_get_recv_poll_fd(nng_socket id, int *fdp); +NNG_DECL int nng_socket_get_send_poll_fd(nng_socket id, int *fdp); + // Utility function for getting a printable form of the socket address // for display in logs, etc. It is not intended to be parsed, and the // display format may change without notice. Generally you should alow @@ -722,8 +734,6 @@ NNG_DECL nng_listener nng_pipe_listener(nng_pipe); #define NNG_OPT_PEERNAME "peer-name" #define NNG_OPT_RECVBUF "recv-buffer" #define NNG_OPT_SENDBUF "send-buffer" -#define NNG_OPT_RECVFD "recv-fd" -#define NNG_OPT_SENDFD "send-fd" #define NNG_OPT_RECVTIMEO "recv-timeout" #define NNG_OPT_SENDTIMEO "send-timeout" #define NNG_OPT_LOCADDR "local-address" -- cgit v1.2.3-70-g09d2