diff options
| author | Garrett D'Amore <garrett@damore.org> | 2025-01-14 23:18:33 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2025-01-14 23:18:33 -0800 |
| commit | b4fdf7a04fc1018f1114fb8ee6f16009752cd16f (patch) | |
| tree | c076e06ebda71da190b9031912bd3bb428bd8fed | |
| parent | a7a2cdb0201a6e85caae621e748cfab03998b6a6 (diff) | |
| download | nng-b4fdf7a04fc1018f1114fb8ee6f16009752cd16f.tar.gz nng-b4fdf7a04fc1018f1114fb8ee6f16009752cd16f.tar.bz2 nng-b4fdf7a04fc1018f1114fb8ee6f16009752cd16f.zip | |
socketpair: use nng_err
| -rw-r--r-- | docs/ref/api/misc.md | 4 | ||||
| -rw-r--r-- | include/nng/nng.h | 2 | ||||
| -rw-r--r-- | src/core/platform.h | 2 | ||||
| -rw-r--r-- | src/nng.c | 2 | ||||
| -rw-r--r-- | src/platform/posix/posix_socketpair.c | 12 |
5 files changed, 12 insertions, 10 deletions
diff --git a/docs/ref/api/misc.md b/docs/ref/api/misc.md index 4e7aec94..7c6b7005 100644 --- a/docs/ref/api/misc.md +++ b/docs/ref/api/misc.md @@ -17,10 +17,10 @@ number facilities when available. ## Create Socket Pair ```c -int nng_socket_pair(int fds[2]); +nng_err nng_socket_pair(int fds[2]); ``` -The `nng_socket_pair` function creates a pair of connected file descriptors. +The {{i:`nng_socket_pair`}} function creates a pair of connected file descriptors. These file descriptors, which are returned in the _fds_ array, are suitable for use with the [Socket transport][socktran]. diff --git a/include/nng/nng.h b/include/nng/nng.h index bec1dd82..e2200f17 100644 --- a/include/nng/nng.h +++ b/include/nng/nng.h @@ -1407,7 +1407,7 @@ NNG_DECL uint32_t nng_random(void); // by reliable, bidirectional, byte streams. This will return NNG_ENOTSUP // if the platform lacks support for this. The argument is a pointer // to an array of file descriptors (or HANDLES or similar). -NNG_DECL int nng_socket_pair(int[2]); +NNG_DECL nng_err nng_socket_pair(int[2]); // Multithreading and synchronization functions. diff --git a/src/core/platform.h b/src/core/platform.h index ca39ac98..bdb8beb4 100644 --- a/src/core/platform.h +++ b/src/core/platform.h @@ -417,7 +417,7 @@ extern int nni_plat_udp_sockname(nni_plat_udp *, nni_sockaddr *); // in APIs to transport file descriptors, or across a fork/exec boundary (so // that child processes may use these with socket to inherit a socket that is // connected to the parent.) -extern int nni_socket_pair(int[2]); +extern nng_err nni_socket_pair(int[2]); // // File/Store Support @@ -2135,7 +2135,7 @@ nng_random(void) return (nni_random()); } -int +nng_err nng_socket_pair(int fds[2]) { return (nni_socket_pair(fds)); diff --git a/src/platform/posix/posix_socketpair.c b/src/platform/posix/posix_socketpair.c index bb2698b7..b2d3ef4d 100644 --- a/src/platform/posix/posix_socketpair.c +++ b/src/platform/posix/posix_socketpair.c @@ -1,5 +1,5 @@ // -// Copyright 2023 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2025 Staysail Systems, Inc. <info@staysail.tech> // // This software is supplied under the terms of the MIT License, a // copy of which should be located in the distribution where this @@ -17,7 +17,7 @@ #include <errno.h> #include <sys/socket.h> -int +nng_err nni_socket_pair(int fds[2]) { int rv; @@ -28,14 +28,16 @@ nni_socket_pair(int fds[2]) #ifdef SO_NOSIGPIPE int set = 1; - setsockopt(fds[0], SOL_SOCKET, SO_NOSIGPIPE, (void *)&set, sizeof(int)); - setsockopt(fds[1], SOL_SOCKET, SO_NOSIGPIPE, (void *)&set, sizeof(int)); + setsockopt( + fds[0], SOL_SOCKET, SO_NOSIGPIPE, (void *) &set, sizeof(int)); + setsockopt( + fds[1], SOL_SOCKET, SO_NOSIGPIPE, (void *) &set, sizeof(int)); #endif return (0); } #else -int +nng_err nni_socket_pair(int fds[2]) { return (NNG_ENOTSUP); |
