[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

@@ -4813,7 +4813,7 @@ mpd_init(void)
CHECK_NULL(L_MPD, evbase_mpd = event_base_new());
CHECK_NULL(L_MPD, cmdbase = commands_base_new(evbase_mpd, NULL));
mpd_sockfd = net_bind(&port, SOCK_STREAM | SOCK_NONBLOCK, "mpd");
mpd_sockfd = net_bind(&port, SOCK_STREAM, "mpd");
if (mpd_sockfd < 0)
{
DPRINTF(E_LOG, L_MPD, "Could not bind mpd server to port %hu\n", port);