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 /include | |
| 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 'include')
| -rw-r--r-- | include/nng/nng.h | 14 |
1 files changed, 12 insertions, 2 deletions
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" |
