1212#endif
1313#define TCPv6_MSS 1220
1414
15- #if defined(LC_WINDOWS )
15+ #if defined(LC_WINDOWS ) && !defined( NXDK )
1616
1717#ifndef SIO_UDP_CONNRESET
1818#define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR, 12)
@@ -70,7 +70,7 @@ void shutdownTcpSocket(SOCKET s) {
7070}
7171
7272int setNonFatalRecvTimeoutMs (SOCKET s , int timeoutMs ) {
73- #if defined(LC_WINDOWS )
73+ #if defined(LC_WINDOWS ) && !defined( NXDK )
7474 // Windows says that SO_RCVTIMEO puts the socket into an indeterminate state
7575 // when a timeout occurs. MSDN doesn't go into it any more than that, but it
7676 // seems likely that they are referring to the inability to know whether a
@@ -93,7 +93,7 @@ int setNonFatalRecvTimeoutMs(SOCKET s, int timeoutMs) {
9393}
9494
9595int pollSockets (struct pollfd * pollFds , int pollFdsCount , int timeoutMs ) {
96- #if defined(LC_WINDOWS )
96+ #if defined(LC_WINDOWS ) && !defined( NXDK )
9797 // We could have used WSAPoll() but it has some nasty bugs
9898 // https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/
9999 //
@@ -206,7 +206,7 @@ int recvUdpSocket(SOCKET s, char* buffer, int size, bool useSelect) {
206206 (LastSocketError () == EWOULDBLOCK ||
207207 LastSocketError () == EINTR ||
208208 LastSocketError () == EAGAIN ||
209- #if defined(LC_WINDOWS )
209+ #if defined(LC_WINDOWS ) && ! defined ( NXDK )
210210 // This error is specific to overlapped I/O which isn't even
211211 // possible to perform with recvfrom(). It seems to randomly
212212 // be returned instead of WSAETIMEDOUT on certain systems.
@@ -221,7 +221,7 @@ int recvUdpSocket(SOCKET s, char* buffer, int size, bool useSelect) {
221221 // We may receive an error due to a previous ICMP Port Unreachable error received
222222 // by this socket. We want to ignore those and continue reading. If the remote party
223223 // is really dead, ENet or TCP connection failures will trigger connection teardown.
224- #if defined(LC_WINDOWS )
224+ #if defined(LC_WINDOWS ) && !defined( NXDK )
225225 } while (err < 0 && LastSocketError () == WSAECONNRESET );
226226#else
227227 } while (err < 0 && LastSocketError () == ECONNREFUSED );
@@ -231,7 +231,7 @@ int recvUdpSocket(SOCKET s, char* buffer, int size, bool useSelect) {
231231}
232232
233233void closeSocket (SOCKET s ) {
234- #if defined(LC_WINDOWS )
234+ #if defined(LC_WINDOWS ) && !defined( NXDK )
235235 closesocket (s );
236236#else
237237 close (s );
@@ -335,7 +335,7 @@ SOCKET bindUdpSocket(int addressFamily, struct sockaddr_storage* localAddr, SOCK
335335 int val = 1 ;
336336 setsockopt (s , SOL_SOCKET , SO_NOSIGPIPE , (char * )& val , sizeof (val ));
337337 }
338- #elif defined(LC_WINDOWS )
338+ #elif defined(LC_WINDOWS ) && !defined( NXDK )
339339 {
340340 // Disable WSAECONNRESET for UDP sockets on Windows
341341 BOOL val = FALSE;
@@ -409,10 +409,10 @@ int setSocketNonBlocking(SOCKET s, bool enabled) {
409409#if defined(__vita__ ) || defined(__HAIKU__ )
410410 int val = enabled ? 1 : 0 ;
411411 return setsockopt (s , SOL_SOCKET , SO_NONBLOCK , (char * )& val , sizeof (val ));
412- #elif defined(O_NONBLOCK )
412+ #elif defined(O_NONBLOCK ) && !defined( NXDK )
413413 return fcntl (s , F_SETFL , (enabled ? O_NONBLOCK : 0 ) | (fcntl (s , F_GETFL ) & ~O_NONBLOCK ));
414414#elif defined(FIONBIO )
415- #ifdef LC_WINDOWS
415+ #if defined( LC_WINDOWS ) && !defined( NXDK )
416416 u_long val = enabled ? 1 : 0 ;
417417#else
418418 int val = enabled ? 1 : 0 ;
@@ -452,7 +452,6 @@ SOCKET connectTcpSocket(struct sockaddr_storage* dstaddr, SOCKADDR_LEN addrlen,
452452 LC_SOCKADDR addr ;
453453 struct pollfd pfd ;
454454 int err ;
455- int val ;
456455
457456 // Create a non-blocking TCP socket
458457 s = createSocket (dstaddr -> ss_family , SOCK_STREAM , IPPROTO_TCP , true);
@@ -471,7 +470,9 @@ SOCKET connectTcpSocket(struct sockaddr_storage* dstaddr, SOCKADDR_LEN addrlen,
471470 // Note: This only changes the max packet size we can *receive* from the host PC.
472471 // We still must split our own sends into smaller chunks with TCP_NODELAY enabled to
473472 // avoid MTU issues on the way out to to the target.
474- #if defined(LC_WINDOWS )
473+ #if defined(LC_WINDOWS ) && !defined(NXDK )
474+ int val ;
475+
475476 // Windows doesn't support setting TCP_MAXSEG but IP_PMTUDISC_DONT forces the MSS to the protocol
476477 // minimum which is what we want here. Linux doesn't do this (disabling PMTUD just avoids setting DF).
477478 if (dstaddr -> ss_family == AF_INET ) {
@@ -491,12 +492,13 @@ SOCKET connectTcpSocket(struct sockaddr_storage* dstaddr, SOCKADDR_LEN addrlen,
491492 // restrict MSS to the minimum. It strips all options out of the SYN packet which
492493 // forces the remote party to fall back to the minimum MSS. TCP_MAXSEG doesn't seem
493494 // to work correctly for outbound connections on macOS/iOS.
494- val = 1 ;
495+ int val = 1 ;
495496 if (setsockopt (s , IPPROTO_TCP , TCP_NOOPT , (char * )& val , sizeof (val )) < 0 ) {
496497 Limelog ("setsockopt(TCP_NOOPT, %d) failed: %d\n" , val , (int )LastSocketError ());
497498 }
498499#elif defined(TCP_MAXSEG )
499- val = dstaddr -> ss_family == AF_INET ? TCPv4_MSS : TCPv6_MSS ;
500+ int val = dstaddr -> ss_family == AF_INET ? TCPv4_MSS : TCPv6_MSS ;
501+
500502 if (setsockopt (s , IPPROTO_TCP , TCP_MAXSEG , (char * )& val , sizeof (val )) < 0 ) {
501503 Limelog ("setsockopt(TCP_MAXSEG, %d) failed: %d\n" , val , (int )LastSocketError ());
502504 }
@@ -1004,12 +1006,12 @@ void exitLowLatencyMode(void) {
10041006}
10051007
10061008int initializePlatformSockets (void ) {
1007- #if defined(LC_WINDOWS )
1009+ #if defined(LC_WINDOWS ) && !defined( NXDK )
10081010 WSADATA data ;
10091011 return WSAStartup (MAKEWORD (2 , 0 ), & data );
10101012#elif defined(__vita__ ) || defined(__WIIU__ ) || defined(__3DS__ )
10111013 return 0 ; // already initialized
1012- #elif defined(LC_POSIX ) && !defined(LC_CHROME )
1014+ #elif defined(LC_POSIX ) && !defined(LC_CHROME ) && !defined( NXDK )
10131015 // Disable SIGPIPE signals to avoid us getting
10141016 // killed when a socket gets an EPIPE error
10151017 struct sigaction sa ;
@@ -1027,7 +1029,7 @@ int initializePlatformSockets(void) {
10271029}
10281030
10291031void cleanupPlatformSockets (void ) {
1030- #if defined(LC_WINDOWS )
1032+ #if defined(LC_WINDOWS ) && !defined( NXDK )
10311033 WSACleanup ();
10321034#else
10331035#endif
0 commit comments