[misc] Use fcntl+O_NONBLOCK when binding instead of socket+SOCK_NONBLOCK

socket() with SOCK_NONBLOCK (O_NONBLOCK) seems not to be possible on MacOS, it
yields 'Protocol wrong type for socket'. Switch to using fcntl() and O_NONBLOCK
instead, hopefully works better cross-platform.

Closes #1644
This commit is contained in:
ejurgensen
2023-08-31 17:16:22 +02:00
parent 9d092c983b
commit 54c2667aea
5 changed files with 63 additions and 20 deletions

View File

@@ -15,15 +15,6 @@
#include <sys/socket.h>
#include <netinet/in.h>
#ifndef SOCK_NONBLOCK
#include <fcntl.h>
#define SOCK_NONBLOCK O_NONBLOCK
#endif
#ifndef SOCK_CLOEXEC
#define SOCK_CLOEXEC 0
#endif
union net_sockaddr
{
struct sockaddr_in sin;