diff options
Diffstat (limited to 'src/conn-tools')
-rw-r--r-- | src/conn-tools/s6-tcpserver4-socketbinder.c | 8 | ||||
-rw-r--r-- | src/conn-tools/s6-tcpserver6-socketbinder.c | 8 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/conn-tools/s6-tcpserver4-socketbinder.c b/src/conn-tools/s6-tcpserver4-socketbinder.c index a37fae1..c02c3a6 100644 --- a/src/conn-tools/s6-tcpserver4-socketbinder.c +++ b/src/conn-tools/s6-tcpserver4-socketbinder.c @@ -3,13 +3,13 @@ #include <skalibs/nonposix.h> #include <stdint.h> #include <unistd.h> +#include <fcntl.h> #include <sys/socket.h> #include <skalibs/types.h> #include <skalibs/sgetopt.h> #include <skalibs/fmtscan.h> #include <skalibs/strerr2.h> -#include <skalibs/djbunix.h> #include <skalibs/socket.h> #include <skalibs/exec.h> @@ -21,7 +21,7 @@ int main (int argc, char const *const *argv) unsigned int backlog = SOMAXCONN ; int flagreuse = 1 ; int flagudp = 0 ; - int flagblocking = 0 ; + unsigned int flags = O_NONBLOCK ; char ip[4] ; uint16_t port ; PROG = "s6-tcpserver4-socketbinder" ; @@ -37,7 +37,7 @@ int main (int argc, char const *const *argv) case 'd' : flagreuse = 1 ; break ; case 'M' : flagudp = 0 ; break ; case 'm' : flagudp = 1 ; break ; - case 'B' : flagblocking = 1 ; break ; + case 'B' : flags = 0 ; break ; case 'b' : if (!uint0_scan(l.arg, &backlog)) dieusage() ; break ; default : dieusage() ; } @@ -47,7 +47,7 @@ int main (int argc, char const *const *argv) if (argc < 3) dieusage() ; if (!ip4_scan(argv[0], ip) || !uint160_scan(argv[1], &port)) dieusage() ; close(0) ; - if (flagudp ? socket_udp4_internal(flagblocking ? 0 : DJBUNIX_FLAG_NB) : socket_tcp4_internal(flagblocking ? 0 : DJBUNIX_FLAG_NB)) + if (flagudp ? socket_udp4_internal(flags) : socket_tcp4_internal(flags)) strerr_diefu1sys(111, "create socket") ; if ((flagreuse ? socket_bind4_reuse(0, ip, port) : socket_bind4(0, ip, port)) < 0) strerr_diefu5sys(111, "bind to ", argv[0], ":", argv[1], " ") ; diff --git a/src/conn-tools/s6-tcpserver6-socketbinder.c b/src/conn-tools/s6-tcpserver6-socketbinder.c index 683dc7c..6890d7e 100644 --- a/src/conn-tools/s6-tcpserver6-socketbinder.c +++ b/src/conn-tools/s6-tcpserver6-socketbinder.c @@ -3,13 +3,13 @@ #include <skalibs/nonposix.h> #include <stdint.h> #include <unistd.h> +#include <fcntl.h> #include <sys/socket.h> #include <skalibs/types.h> #include <skalibs/sgetopt.h> #include <skalibs/fmtscan.h> #include <skalibs/strerr2.h> -#include <skalibs/djbunix.h> #include <skalibs/socket.h> #include <skalibs/exec.h> @@ -21,7 +21,7 @@ int main (int argc, char const *const *argv) unsigned int backlog = SOMAXCONN ; int flagreuse = 1 ; int flagudp = 0 ; - int flagblocking = 0 ; + unsigned int flags = O_NONBLOCK ; char ip[16] ; uint16_t port ; PROG = "s6-tcpserver6-socketbinder" ; @@ -37,7 +37,7 @@ int main (int argc, char const *const *argv) case 'd' : flagreuse = 1 ; break ; case 'M' : flagudp = 0 ; break ; case 'm' : flagudp = 1 ; break ; - case 'B' : flagblocking = 1 ; break ; + case 'B' : flags = 0 ; break ; case 'b' : if (!uint0_scan(l.arg, &backlog)) dieusage() ; break ; default : dieusage() ; } @@ -47,7 +47,7 @@ int main (int argc, char const *const *argv) if (argc < 3) dieusage() ; if (!ip6_scan(argv[0], ip) || !uint160_scan(argv[1], &port)) dieusage() ; close(0) ; - if (flagudp ? socket_udp6_internal(flagblocking ? 0 : DJBUNIX_FLAG_NB) : socket_tcp6_internal(flagblocking ? 0 : DJBUNIX_FLAG_NB)) + if (flagudp ? socket_udp6_internal(flags) : socket_tcp6_internal(flags)) strerr_diefu1sys(111, "create socket") ; if ((flagreuse ? socket_bind6_reuse(0, ip, port) : socket_bind6(0, ip, port)) < 0) strerr_diefu5sys(111, "bind to ", argv[0], ":", argv[1], " ") ; |