From 0d0a857c696b653a65c709bbfb11bdaff67369b8 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 30 Apr 2014 03:32:36 +0200 Subject: Use SOCK_NONBLOCK where available --- src/socket.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/socket.c') diff --git a/src/socket.c b/src/socket.c index d49888c..340967c 100644 --- a/src/socket.c +++ b/src/socket.c @@ -33,7 +33,7 @@ static int bind_socket(const fastd_bind_address_t *addr, bool warn) { int af = AF_UNSPEC; if (addr->addr.sa.sa_family != AF_INET) { - fd = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP); + fd = socket(PF_INET6, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_UDP); if (fd >= 0) { af = AF_INET6; @@ -46,7 +46,7 @@ static int bind_socket(const fastd_bind_address_t *addr, bool warn) { } } if (fd < 0 && addr->addr.sa.sa_family != AF_INET6) { - fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); + fd = socket(PF_INET, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_UDP); if (fd < 0) exit_errno("unable to create socket"); else @@ -56,7 +56,9 @@ static int bind_socket(const fastd_bind_address_t *addr, bool warn) { if (fd < 0) goto error; - fastd_setfl(fd, O_NONBLOCK); +#ifdef NO_HAVE_SOCK_NONBLOCK + fastd_setnonblock(fd); +#endif int one = 1; -- cgit v1.2.3