aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-11-02 13:57:53 -0700
committerGarrett D'Amore <garrett@damore.org>2024-11-02 14:47:50 -0700
commit279180c1d07fc2c4c0bfa8f5a418cb02c4b87863 (patch)
treeb451ac7f845062674d6ab45eb5d530628d3ff47c /tests
parent9b27984d0e2da430b78a975e59f55c96de5f6056 (diff)
downloadnng-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 'tests')
-rw-r--r--tests/nonblock.c2
-rw-r--r--tests/pollfd.c31
2 files changed, 8 insertions, 25 deletions
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);
});
})