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. --- tests/nonblock.c | 2 +- tests/pollfd.c | 31 +++++++------------------------ 2 files changed, 8 insertions(+), 25 deletions(-) (limited to 'tests') diff --git a/tests/nonblock.c b/tests/nonblock.c index 19174882..624c9233 100644 --- a/tests/nonblock.c +++ b/tests/nonblock.c @@ -35,7 +35,7 @@ repthr(void *arg) nng_listen(rep, addr, &l, NNG_FLAG_NONBLOCK); - nng_socket_get_int(rep, NNG_OPT_RECVFD, &ifd); + nng_socket_get_recv_poll_fd(rep, &ifd); fd = ifd; for (;;) { diff --git a/tests/pollfd.c b/tests/pollfd.c index adb9d806..5cc2d89a 100644 --- a/tests/pollfd.c +++ b/tests/pollfd.c @@ -53,18 +53,14 @@ TestMain("Poll FDs", { nng_msleep(50); Convey("We can get a recv FD", { - int fd; - size_t sz; + int fd; - sz = sizeof(fd); - So(nng_socket_get(s1, NNG_OPT_RECVFD, &fd, &sz) == 0); + So(nng_socket_get_recv_poll_fd(s1, &fd) == 0); So(fd != (int) INVALID_SOCKET); Convey("And it is always the same fd", { int fd2; - sz = sizeof(fd2); - So(nng_socket_get( - s1, NNG_OPT_RECVFD, &fd2, &sz) == 0); + So(nng_socket_get_recv_poll_fd(s1, &fd2) == 0); So(fd2 == fd); }); @@ -91,25 +87,12 @@ TestMain("Poll FDs", { }); Convey("We can get a send FD", { - int fd; - size_t sz; + int fd; - sz = sizeof(fd); - So(nng_socket_get(s1, NNG_OPT_SENDFD, &fd, &sz) == 0); + So(nng_socket_get_send_poll_fd(s1, &fd) == 0); So(fd != (int) INVALID_SOCKET); So(nng_send(s1, "oops", 4, 0) == 0); }); - - Convey("Must have a big enough size", { - int fd; - size_t sz; - sz = 1; - So(nng_socket_get(s1, NNG_OPT_RECVFD, &fd, &sz) == - NNG_EINVAL); - sz = 128; - So(nng_socket_get(s1, NNG_OPT_RECVFD, &fd, &sz) == 0); - So(sz == sizeof(fd)); - }); }); Convey("We cannot get a send FD for PULL", { @@ -117,7 +100,7 @@ TestMain("Poll FDs", { int fd; So(nng_pull0_open(&s3) == 0); Reset({ nng_close(s3); }); - So(nng_socket_get_int(s3, NNG_OPT_SENDFD, &fd) == NNG_ENOTSUP); + So(nng_socket_get_send_poll_fd(s3, &fd) == NNG_ENOTSUP); }); Convey("We cannot get a recv FD for PUSH", { @@ -125,6 +108,6 @@ TestMain("Poll FDs", { int fd; So(nng_push0_open(&s3) == 0); Reset({ nng_close(s3); }); - So(nng_socket_get_int(s3, NNG_OPT_RECVFD, &fd) == NNG_ENOTSUP); + So(nng_socket_get_recv_poll_fd(s3, &fd) == NNG_ENOTSUP); }); }) -- cgit v1.2.3-70-g09d2