-
-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
111 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# | ||
# Copyright 2020 Staysail Systems, Inc. <[email protected]> | ||
# Copyright 2023 Staysail Systems, Inc. <[email protected]> | ||
# | ||
# This software is supplied under the terms of the MIT License, a | ||
# copy of which should be located in the distribution where this | ||
|
@@ -61,6 +61,7 @@ if (NNG_PLATFORM_POSIX) | |
nng_check_sym(LOCAL_PEERPID sys/un.h NNG_HAVE_LOCALPEERPID) | ||
nng_check_sym(getpeerucred ucred.h NNG_HAVE_GETPEERUCRED) | ||
nng_check_sym(atomic_flag_test_and_set stdatomic.h NNG_HAVE_STDATOMIC) | ||
nng_check_sym(socketpair sys/socket.h NNG_HAVE_SOCKETPAIR) | ||
|
||
nng_sources( | ||
posix_impl.h | ||
|
@@ -82,6 +83,7 @@ if (NNG_PLATFORM_POSIX) | |
posix_pipe.c | ||
posix_resolv_gai.c | ||
posix_sockaddr.c | ||
posix_socketpair.c | ||
posix_tcpconn.c | ||
posix_tcpdial.c | ||
posix_tcplisten.c | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// Copyright 2023 Staysail Systems, Inc. <[email protected]> | ||
// | ||
// This software is supplied under the terms of the MIT License, a | ||
// copy of which should be located in the distribution where this | ||
// file was obtained (LICENSE.txt). A copy of the license may also be | ||
// found online at https://opensource.org/licenses/MIT. | ||
// | ||
|
||
#include "core/nng_impl.h" | ||
|
||
#ifdef NNG_HAVE_SOCKETPAIR | ||
// This provides an implementation of socketpair(), which is supposed | ||
// to be present on XPG6 and newer. This trivial implementation | ||
// only supports SOCK_STREAM over AF_UNIX. Which is sufficient for | ||
// most purposes. The fds array should point to an int[2]. | ||
#include <errno.h> | ||
#include <sys/socket.h> | ||
|
||
int | ||
nni_socket_pair(int *fds) | ||
{ | ||
int rv; | ||
rv = socketpair(PF_UNIX, SOCK_STREAM, 0, fds); | ||
if (rv != 0) { | ||
return (nni_plat_errno(errno)); | ||
} | ||
|
||
return (0); | ||
} | ||
#else | ||
int | ||
nni_socket_pair(int *fds) | ||
{ | ||
return (NNG_ENOTSUP); | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// Copyright 2023 Staysail Systems, Inc. <[email protected]> | ||
// | ||
// This software is supplied under the terms of the MIT License, a | ||
// copy of which should be located in the distribution where this | ||
// file was obtained (LICENSE.txt). A copy of the license may also be | ||
// found online at https://opensource.org/licenses/MIT. | ||
// | ||
|
||
#include "core/nng_impl.h" | ||
|
||
|
||
#ifdef NNG_HAVE_SOCKETPAIR_TODO | ||
// TODO: Windows lacks socketpair. We can emulate it with an explcit | ||
// implementation based on AF_UNIX. | ||
|
||
#include <errno.h> | ||
#include <sys/socket.h> | ||
|
||
int | ||
nni_socket_pair(int *fds) | ||
{ | ||
int rv; | ||
rv = socketpair(PF_UNIX, SOCK_STREAM, 0, fds); | ||
if (rv != 0) { | ||
return (nni_plat_errno(errno)); | ||
} | ||
|
||
return (0); | ||
} | ||
#else | ||
int | ||
nni_socket_pair(int *fds) | ||
{ | ||
return (NNG_ENOTSUP); | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters