diff options
Diffstat (limited to 'apps/nc/compat/socket.c')
-rw-r--r-- | apps/nc/compat/socket.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/apps/nc/compat/socket.c b/apps/nc/compat/socket.c new file mode 100644 index 0000000..fd699f9 --- /dev/null +++ b/apps/nc/compat/socket.c | |||
@@ -0,0 +1,29 @@ | |||
1 | #define SOCKET_FLAGS_PRIV | ||
2 | |||
3 | #include <sys/socket.h> | ||
4 | |||
5 | #ifdef NEED_SOCKET_FLAGS | ||
6 | |||
7 | #include <fcntl.h> | ||
8 | |||
9 | int | ||
10 | _socket(int domain, int type, int protocol) | ||
11 | { | ||
12 | int s = socket(domain, type & ~(SOCK_CLOEXEC | SOCK_NONBLOCK), protocol); | ||
13 | int flags; | ||
14 | if (s == -1) | ||
15 | return s; | ||
16 | |||
17 | if (type & SOCK_CLOEXEC) { | ||
18 | flags = fcntl(s, F_GETFD); | ||
19 | fcntl(s, F_SETFD, flags | FD_CLOEXEC); | ||
20 | } | ||
21 | |||
22 | if (type & SOCK_NONBLOCK) { | ||
23 | flags = fcntl(s, F_GETFL); | ||
24 | fcntl(s, F_SETFL, flags | O_NONBLOCK); | ||
25 | } | ||
26 | return s; | ||
27 | } | ||
28 | |||
29 | #endif | ||