mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-17 17:05:50 +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/thread.h>
|
||||||
#include <coreinit/fastmutex.h>
|
#include <coreinit/fastmutex.h>
|
||||||
#include <coreinit/fastcondition.h>
|
#include <coreinit/fastcondition.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
@ -39,6 +40,7 @@
|
|||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -299,11 +299,13 @@ int setSocketNonBlocking(SOCKET s, bool enabled) {
|
|||||||
#if defined(__vita__)
|
#if defined(__vita__)
|
||||||
int val = enabled ? 1 : 0;
|
int val = enabled ? 1 : 0;
|
||||||
return setsockopt(s, SOL_SOCKET, SO_NONBLOCK, (char*)&val, sizeof(val));
|
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)
|
#elif defined(FIONBIO)
|
||||||
int val = enabled ? 1 : 0;
|
int val = enabled ? 1 : 0;
|
||||||
return ioctlsocket(s, FIONBIO, &val);
|
return ioctlsocket(s, FIONBIO, &val);
|
||||||
#else
|
#else
|
||||||
return SOCKET_ERROR;
|
#error Please define your platform's non-blocking sockets API!
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user