mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-17 08:55:48 +00:00
Use O_NONBLOCK for platforms without support for FIONBIO
This commit is contained in:
parent
c00f4e15ae
commit
52250b4815
@ -32,6 +32,7 @@
|
||||
#include <coreinit/thread.h>
|
||||
#include <coreinit/fastmutex.h>
|
||||
#include <coreinit/fastcondition.h>
|
||||
#include <fcntl.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
@ -39,6 +40,7 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -299,11 +299,13 @@ int setSocketNonBlocking(SOCKET s, bool enabled) {
|
||||
#if defined(__vita__)
|
||||
int val = enabled ? 1 : 0;
|
||||
return setsockopt(s, SOL_SOCKET, SO_NONBLOCK, (char*)&val, sizeof(val));
|
||||
#elif defined(O_NONBLOCK)
|
||||
return fcntl(s, F_SETFL, (enabled ? O_NONBLOCK : 0) | (fcntl(s, F_GETFL) & ~O_NONBLOCK));
|
||||
#elif defined(FIONBIO)
|
||||
int val = enabled ? 1 : 0;
|
||||
return ioctlsocket(s, FIONBIO, &val);
|
||||
#else
|
||||
return SOCKET_ERROR;
|
||||
#error Please define your platform's non-blocking sockets API!
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user