rebase for the 4th time
This commit is contained in:
@@ -4,28 +4,23 @@
|
||||
#include "..\..\Common\Network\PlatformNetworkManager.h"
|
||||
#include "..\..\..\Minecraft.World\Socket.h"
|
||||
|
||||
#if defined _WINDOWS64 || defined _XBOX
|
||||
SOCKET NetworkSocketLayer::s_listenSocket = INVALID_SOCKET;
|
||||
SOCKET NetworkSocketLayer::s_hostConnectionSocket = INVALID_SOCKET;
|
||||
SOCKET NetworkSocketLayer::s_advertiseSock = INVALID_SOCKET;
|
||||
SOCKET NetworkSocketLayer::s_discoverySock = INVALID_SOCKET;
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
SOCKET NetworkSocketLayer::s_listenSocket = -1;
|
||||
SOCKET NetworkSocketLayer::s_hostConnectionSocket = -1;
|
||||
SOCKET NetworkSocketLayer::s_advertiseSock = -1;
|
||||
SOCKET NetworkSocketLayer::s_discoverySock = -1;
|
||||
|
||||
#if defined __PS3__
|
||||
#define LCE_NET_ERRNO sys_net_errno
|
||||
int closesocket(int s) { return socketclose(s); };
|
||||
#if defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
void WSACleanup() {};
|
||||
#endif
|
||||
|
||||
#ifdef __PS3__
|
||||
void terminate_networking() { cellNetCtlTerm(); sys_net_finalize_network(); };
|
||||
#elif defined __ORBIS__
|
||||
#define LCE_NET_ERRNO errno
|
||||
int closesocket(int s) { return sceNetSocketClose(s); };
|
||||
int socketclose(int s) { return sceNetSocketClose(s); };
|
||||
#else
|
||||
void terminate_networking() {};
|
||||
#endif
|
||||
void WSACleanup() {};
|
||||
|
||||
#if defined __PSVITA__
|
||||
int socket(int family, int type, int protocol) { return sceNetSocket(NULL, family, type, protocol); };
|
||||
#endif
|
||||
|
||||
C4JThread* NetworkSocketLayer::s_acceptThread = NULL;
|
||||
@@ -62,6 +57,9 @@ std::vector<BYTE> NetworkSocketLayer::s_disconnectedSmallIds;
|
||||
CRITICAL_SECTION NetworkSocketLayer::s_freeSmallIdLock;
|
||||
std::vector<BYTE> NetworkSocketLayer::s_freeSmallIds;
|
||||
|
||||
// only goes true on a successful Initialize(), and a failed one gets retried
|
||||
static bool s_locksCreated = false;
|
||||
|
||||
bool g_MultiplayerHost = false;
|
||||
#if defined __ORBIS__
|
||||
// Orbis has direct lan networking so it can bypass psn account checks
|
||||
@@ -77,6 +75,19 @@ char g_MultiplayerIP[256] = "127.0.0.1";
|
||||
bool NetworkSocketLayer::Initialize()
|
||||
{
|
||||
if (s_initialized) return true;
|
||||
|
||||
// Create the locks before touching the platform network stack.
|
||||
if (!s_locksCreated)
|
||||
{
|
||||
InitializeCriticalSection(&s_sendLock);
|
||||
InitializeCriticalSection(&s_connectionsLock);
|
||||
InitializeCriticalSection(&s_advertiseLock);
|
||||
InitializeCriticalSection(&s_discoveryLock);
|
||||
InitializeCriticalSection(&s_disconnectLock);
|
||||
InitializeCriticalSection(&s_freeSmallIdLock);
|
||||
s_locksCreated = true;
|
||||
}
|
||||
|
||||
#if defined _WINDOWS64 || defined _XBOX
|
||||
WSADATA wsaData;
|
||||
int result = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||
@@ -98,14 +109,21 @@ bool NetworkSocketLayer::Initialize()
|
||||
sys_net_finalize_network();
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
#elif defined __PSVITA__
|
||||
SceNetInitParam param;
|
||||
static char memory[16 * 1024];
|
||||
|
||||
InitializeCriticalSection(&s_sendLock);
|
||||
InitializeCriticalSection(&s_connectionsLock);
|
||||
InitializeCriticalSection(&s_advertiseLock);
|
||||
InitializeCriticalSection(&s_discoveryLock);
|
||||
InitializeCriticalSection(&s_disconnectLock);
|
||||
InitializeCriticalSection(&s_freeSmallIdLock);
|
||||
param.memory = memory;
|
||||
param.size = sizeof(memory);
|
||||
param.flags = 0;
|
||||
|
||||
int result = sceNetInit(¶m);
|
||||
// libnet is brought up before us by the platform layer, which reports EBUSY here.
|
||||
if (result < 0 && result != SCE_NET_ERROR_EBUSY) {
|
||||
app.DebugPrintf("sceNetInit failed: 0x%08x\n", result);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
s_initialized = true;
|
||||
|
||||
@@ -134,7 +152,7 @@ void NetworkSocketLayer::Shutdown()
|
||||
closesocket(s_hostConnectionSocket);
|
||||
s_hostConnectionSocket = INVALID_SOCKET;
|
||||
}
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
if (s_listenSocket >= 0)
|
||||
{
|
||||
socketclose(s_listenSocket);
|
||||
@@ -155,7 +173,7 @@ void NetworkSocketLayer::Shutdown()
|
||||
s_connections[i].active = false;
|
||||
#if defined _WINDOWS64 || defined _XBOX
|
||||
if (s_connections[i].tcpSocket != INVALID_SOCKET)
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
if (s_connections[i].tcpSocket >= 0)
|
||||
#endif
|
||||
{
|
||||
@@ -189,6 +207,7 @@ void NetworkSocketLayer::Shutdown()
|
||||
s_disconnectedSmallIds.clear();
|
||||
DeleteCriticalSection(&s_freeSmallIdLock);
|
||||
s_freeSmallIds.clear();
|
||||
s_locksCreated = false;
|
||||
WSACleanup();
|
||||
s_initialized = false;
|
||||
}
|
||||
@@ -247,8 +266,12 @@ bool NetworkSocketLayer::HostGame(int port)
|
||||
app.DebugPrintf("socket() failed: %d\n", WSAGetLastError());
|
||||
return false;
|
||||
}
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
#ifdef __PSVITA__
|
||||
SceNetSockaddrIn addr = {};
|
||||
#else
|
||||
struct sockaddr_in addr = {};
|
||||
#endif
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
addr.sin_port = htons((uint16_t)port);
|
||||
@@ -301,8 +324,12 @@ bool NetworkSocketLayer::HostGame(int port)
|
||||
s_listenSocket = INVALID_SOCKET;
|
||||
return false;
|
||||
}
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
#ifdef __PSVITA__
|
||||
iResult = ::bind(s_listenSocket, (const sockaddr*)&addr, sizeof(addr));
|
||||
#else
|
||||
iResult = ::bind(s_listenSocket, (struct sockaddr*)&addr, sizeof(addr));
|
||||
#endif
|
||||
if (iResult < 0)
|
||||
{
|
||||
app.DebugPrintf("bind() failed: %d\n", iResult);
|
||||
@@ -555,14 +582,18 @@ bool NetworkSocketLayer::JoinGame(const char *ip, int port)
|
||||
connected = true;
|
||||
break;
|
||||
}
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
if (s_hostConnectionSocket != -1)
|
||||
{
|
||||
socketclose(s_hostConnectionSocket);
|
||||
s_hostConnectionSocket = -1;
|
||||
}
|
||||
|
||||
#ifdef __PSVITA__
|
||||
SceNetSockaddrIn addr = {};
|
||||
#else
|
||||
struct sockaddr_in addr = {};
|
||||
#endif
|
||||
|
||||
#if defined(__ORBIS__)
|
||||
addr.sin_len = sizeof(addr);
|
||||
@@ -602,41 +633,47 @@ bool NetworkSocketLayer::JoinGame(const char *ip, int port)
|
||||
setsockopt(s_hostConnectionSocket, IPPROTO_TCP, TCP_NODELAY, (const char *)&noDelay, sizeof(noDelay));
|
||||
|
||||
int nonBlocking = 1;
|
||||
#ifdef __PS3__
|
||||
setsockopt(s_hostConnectionSocket, SOL_SOCKET, SO_NBIO, &nonBlocking, sizeof(nonBlocking));
|
||||
#elif defined(__ORBIS__)
|
||||
setsockopt(s_hostConnectionSocket, SOL_SOCKET, SCE_NET_SO_NBIO, &nonBlocking, sizeof(nonBlocking));
|
||||
#endif
|
||||
|
||||
#ifdef __PSVITA__
|
||||
iResult = connect(s_hostConnectionSocket, (const SceNetSockaddr*)&addr, sizeof(addr));
|
||||
#else
|
||||
iResult = connect(s_hostConnectionSocket, (struct sockaddr*)&addr, sizeof(addr));
|
||||
int connectError = iResult < 0 ? LCE_NET_ERRNO : 0;
|
||||
#endif
|
||||
if (iResult < 0)
|
||||
{
|
||||
#if defined(__PS3__)
|
||||
int err = connectError;
|
||||
int err = sys_net_errno;
|
||||
if (err == SYS_NET_EINPROGRESS)
|
||||
{
|
||||
#elif defined(__ORBIS__)
|
||||
int err = connectError;
|
||||
if (err == EINPROGRESS)
|
||||
{
|
||||
#endif
|
||||
#ifndef __PSVITA__
|
||||
fd_set writeFds, exceptFds;
|
||||
FD_ZERO(&writeFds);
|
||||
FD_ZERO(&exceptFds);
|
||||
FD_SET(s_hostConnectionSocket, &writeFds);
|
||||
FD_SET(s_hostConnectionSocket, &exceptFds);
|
||||
|
||||
struct timeval tv;
|
||||
tv.tv_sec = connectTimeoutMs / 1000;
|
||||
tv.tv_usec = (connectTimeoutMs % 1000) * 1000;
|
||||
|
||||
#if defined(__PS3__)
|
||||
int selectResult = socketselect(s_hostConnectionSocket + 1, NULL, &writeFds, &exceptFds, &tv);
|
||||
#elif defined(__ORBIS__)
|
||||
int selectResult = select(s_hostConnectionSocket + 1, NULL, &writeFds, &exceptFds, &tv);
|
||||
#else
|
||||
SceNetId eid = sceNetEpollCreate(NULL, 0);
|
||||
SceNetEpollEvent ev = {};
|
||||
ev.events = SCE_NET_EPOLLOUT;
|
||||
ev.data.fd = s_hostConnectionSocket;
|
||||
sceNetEpollControl(eid, SCE_NET_EPOLL_CTL_ADD, s_hostConnectionSocket, &ev);
|
||||
int timeoutUsec = connectTimeoutMs * 1000;
|
||||
SceNetEpollEvent outEvents[1];
|
||||
int selectResult = sceNetEpollWait(eid, outEvents, 1, timeoutUsec);
|
||||
sceNetEpollControl(eid, SCE_NET_EPOLL_CTL_DEL, s_hostConnectionSocket, NULL);
|
||||
sceNetEpollDestroy(eid);
|
||||
#endif
|
||||
|
||||
#ifndef __PSVITA__
|
||||
int selectResult = socketselect(s_hostConnectionSocket + 1, NULL, &writeFds, &exceptFds, &tv);
|
||||
if (selectResult <= 0 || FD_ISSET(s_hostConnectionSocket, &exceptFds))
|
||||
#else
|
||||
if (selectResult <= 0 || (selectResult > 0) &&
|
||||
(outEvents[0].events & (SCE_NET_EPOLLERR | SCE_NET_EPOLLHUP)))
|
||||
#endif
|
||||
{
|
||||
app.DebugPrintf("connect() to %s:%d timed out or failed (attempt %d/%d)\n", ip, port, attempt + 1, maxAttempts);
|
||||
closesocket(s_hostConnectionSocket);
|
||||
@@ -667,7 +704,7 @@ bool NetworkSocketLayer::JoinGame(const char *ip, int port)
|
||||
int blocking = 0;
|
||||
#ifdef __PS3__
|
||||
setsockopt(s_hostConnectionSocket, SOL_SOCKET, SO_NBIO, &blocking, sizeof(blocking));
|
||||
#elif defined(__ORBIS__)
|
||||
#elif defined(__ORBIS__) || defined __PSVITA__
|
||||
setsockopt(s_hostConnectionSocket, SOL_SOCKET, SCE_NET_SO_NBIO, &blocking, sizeof(blocking));
|
||||
#endif
|
||||
|
||||
@@ -721,7 +758,7 @@ bool NetworkSocketLayer::SendOnSocket(SOCKET sock, const void *data, int dataSiz
|
||||
{
|
||||
#if defined _WINDOWS64 || defined _XBOX
|
||||
if (sock == INVALID_SOCKET || dataSize <= 0) return false;
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
if (sock < 0 || dataSize <= 0) return false;
|
||||
#endif
|
||||
|
||||
@@ -740,7 +777,7 @@ bool NetworkSocketLayer::SendOnSocket(SOCKET sock, const void *data, int dataSiz
|
||||
int sent = send(sock, (const char *)header + totalSent, toSend - totalSent, 0);
|
||||
#if defined _WINDOWS64 || defined _XBOX
|
||||
if (sent == SOCKET_ERROR || sent == 0)
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
if (sent < 0 || sent == 0)
|
||||
#endif
|
||||
{
|
||||
@@ -757,7 +794,7 @@ bool NetworkSocketLayer::SendOnSocket(SOCKET sock, const void *data, int dataSiz
|
||||
|
||||
#if defined _WINDOWS64 || defined _XBOX
|
||||
if (sent == SOCKET_ERROR || sent == 0)
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
if (sent < 0 || sent == 0)
|
||||
#endif
|
||||
{
|
||||
@@ -780,7 +817,7 @@ bool NetworkSocketLayer::SendToSmallId(BYTE targetSmallId, const void *data, int
|
||||
SOCKET sock = GetSocketForSmallId(targetSmallId);
|
||||
#if defined _WINDOWS64 || defined _XBOX
|
||||
if (sock == INVALID_SOCKET) return false;
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
if (sock < 0) return false;
|
||||
#endif
|
||||
return SendOnSocket(sock, data, dataSize);
|
||||
@@ -806,7 +843,7 @@ SOCKET NetworkSocketLayer::GetSocketForSmallId(BYTE smallId)
|
||||
LeaveCriticalSection(&s_connectionsLock);
|
||||
#if defined _WINDOWS64 || defined _XBOX
|
||||
return INVALID_SOCKET;
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
@@ -848,7 +885,11 @@ int NetworkSocketLayer::AcceptThreadProc(LPVOID param)
|
||||
{
|
||||
while (s_active)
|
||||
{
|
||||
#ifdef __PSVITA__
|
||||
SOCKET clientSocket = accept(s_listenSocket, (SceNetSockaddr *)NULL, NULL);
|
||||
#else
|
||||
SOCKET clientSocket = accept(s_listenSocket, NULL, NULL);
|
||||
#endif
|
||||
#if defined _WINDOWS64 || defined _XBOX
|
||||
if (clientSocket == INVALID_SOCKET)
|
||||
{
|
||||
@@ -856,7 +897,7 @@ int NetworkSocketLayer::AcceptThreadProc(LPVOID param)
|
||||
app.DebugPrintf("accept() failed: %d\n", WSAGetLastError());
|
||||
break;
|
||||
}
|
||||
#elif __PS3__ || defined __ORBIS__
|
||||
#elif __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
if (clientSocket < 0)
|
||||
{
|
||||
if (s_active)
|
||||
@@ -1063,7 +1104,7 @@ int NetworkSocketLayer::ClientRecvThreadProc(LPVOID param)
|
||||
|
||||
#if defined _WINDOWS64 || defined _XBOX
|
||||
while (s_active && s_hostConnectionSocket != INVALID_SOCKET)
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
while (s_active && s_hostConnectionSocket >= 0)
|
||||
#endif
|
||||
{
|
||||
@@ -1128,7 +1169,7 @@ bool NetworkSocketLayer::StartAdvertising(int gamePort, const wchar_t *hostName,
|
||||
app.DebugPrintf("Win64 LAN: Failed to create advertise socket: %d\n", WSAGetLastError());
|
||||
return false;
|
||||
}
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
if (s_advertiseSock < 0)
|
||||
{
|
||||
app.DebugPrintf("PS3 LAN: Failed to create advertise socket: %d\n", s_advertiseSock);
|
||||
@@ -1156,7 +1197,7 @@ void NetworkSocketLayer::StopAdvertising()
|
||||
closesocket(s_advertiseSock);
|
||||
s_advertiseSock = INVALID_SOCKET;
|
||||
}
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
if (s_advertiseSock >= 0)
|
||||
{
|
||||
closesocket(s_advertiseSock);
|
||||
@@ -1200,7 +1241,11 @@ void NetworkSocketLayer::UpdateAdvertiseJoinable(bool joinable)
|
||||
|
||||
int NetworkSocketLayer::AdvertiseThreadProc(LPVOID param)
|
||||
{
|
||||
#ifdef __PSVITA__
|
||||
SceNetSockaddrIn broadcastAddr;
|
||||
#else
|
||||
struct sockaddr_in broadcastAddr;
|
||||
#endif
|
||||
memset(&broadcastAddr, 0, sizeof(broadcastAddr));
|
||||
broadcastAddr.sin_family = AF_INET;
|
||||
broadcastAddr.sin_port = htons(NETWORK_LAN_DISCOVERY_PORT);
|
||||
@@ -1218,15 +1263,20 @@ int NetworkSocketLayer::AdvertiseThreadProc(LPVOID param)
|
||||
data.gameHostSettings = htonl(data.gameHostSettings);
|
||||
data.texturePackParentId = htonl(data.texturePackParentId);
|
||||
|
||||
#ifdef __PSVITA__
|
||||
int sent = sendto(s_advertiseSock, (const char *)&data, sizeof(data), 0,
|
||||
(const sockaddr *)&broadcastAddr, sizeof(broadcastAddr));
|
||||
#else
|
||||
int sent = sendto(s_advertiseSock, (const char *)&data, sizeof(data), 0,
|
||||
(struct sockaddr *)&broadcastAddr, sizeof(broadcastAddr));
|
||||
#endif
|
||||
|
||||
#if defined _WINDOWS64 || defined _XBOX
|
||||
if (sent == SOCKET_ERROR && s_advertising)
|
||||
{
|
||||
app.DebugPrintf("Win64 LAN: Broadcast sendto failed: %d\n", WSAGetLastError());
|
||||
}
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
if (sent < 0 && s_advertising)
|
||||
{
|
||||
app.DebugPrintf("PS3 LAN: Broadcast sendto failed: %d\n", sent);
|
||||
@@ -1251,7 +1301,7 @@ bool NetworkSocketLayer::StartDiscovery()
|
||||
app.DebugPrintf("Win64 LAN: Failed to create discovery socket: %d\n", WSAGetLastError());
|
||||
return false;
|
||||
}
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
app.DebugPrintf("Discovery socket: %d\n", s_discoverySock);
|
||||
if (s_discoverySock < 0)
|
||||
{
|
||||
@@ -1263,8 +1313,12 @@ bool NetworkSocketLayer::StartDiscovery()
|
||||
|
||||
BOOL reuseAddr = TRUE;
|
||||
setsockopt(s_discoverySock, SOL_SOCKET, SO_REUSEADDR, (const char *)&reuseAddr, sizeof(reuseAddr));
|
||||
|
||||
|
||||
#ifdef __PSVITA__
|
||||
SceNetSockaddrIn bindAddr;
|
||||
#else
|
||||
struct sockaddr_in bindAddr;
|
||||
#endif
|
||||
memset(&bindAddr, 0, sizeof(bindAddr));
|
||||
bindAddr.sin_family = AF_INET;
|
||||
bindAddr.sin_port = htons(NETWORK_LAN_DISCOVERY_PORT);
|
||||
@@ -1278,14 +1332,15 @@ bool NetworkSocketLayer::StartDiscovery()
|
||||
s_discoverySock = INVALID_SOCKET;
|
||||
return false;
|
||||
}
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
#ifdef __PSVITA__
|
||||
if (::bind(s_discoverySock, (const sockaddr *)&bindAddr, sizeof(bindAddr)) < 0)
|
||||
{
|
||||
#else
|
||||
if (::bind(s_discoverySock, (struct sockaddr *)&bindAddr, sizeof(bindAddr)) < 0)
|
||||
{
|
||||
#if defined(__PS3__)
|
||||
app.DebugPrintf("PS3 LAN: Discovery bind failed: %d\n", sys_net_errno);
|
||||
#elif defined(__ORBIS__)
|
||||
app.DebugPrintf("PS3 LAN: Discovery bind failed: %d\n", sce_net_errno);
|
||||
#endif
|
||||
app.DebugPrintf("PS3 LAN: Discovery bind failed: %d\n", sys_net_errno);
|
||||
socketclose(s_discoverySock);
|
||||
s_discoverySock = -1;
|
||||
return false;
|
||||
@@ -1319,7 +1374,7 @@ void NetworkSocketLayer::StopDiscovery()
|
||||
closesocket(s_discoverySock);
|
||||
s_discoverySock = INVALID_SOCKET;
|
||||
}
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
if (s_discoverySock >= 0)
|
||||
{
|
||||
socketclose(s_discoverySock);
|
||||
@@ -1357,22 +1412,31 @@ int NetworkSocketLayer::DiscoveryThreadProc(LPVOID param)
|
||||
|
||||
while (s_discovering)
|
||||
{
|
||||
#ifdef __PSVITA__
|
||||
SceNetSockaddrIn senderAddr;
|
||||
#else
|
||||
struct sockaddr_in senderAddr;
|
||||
#endif
|
||||
#if defined _WINDOWS64 || defined _XBOX
|
||||
int senderLen = sizeof(senderAddr);
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
socklen_t senderLen = sizeof(senderAddr);
|
||||
#endif
|
||||
|
||||
#ifdef __PSVITA__
|
||||
int recvLen = recvfrom(s_discoverySock, recvBuf, sizeof(recvBuf), 0,
|
||||
(sockaddr *)&senderAddr, &senderLen);
|
||||
#else
|
||||
int recvLen = recvfrom(s_discoverySock, recvBuf, sizeof(recvBuf), 0,
|
||||
(struct sockaddr *)&senderAddr, &senderLen);
|
||||
#endif
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
if (recvLen == SOCKET_ERROR)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
#elif defined __PS3__ || defined __ORBIS__
|
||||
#elif defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
|
||||
if (recvLen < 0)
|
||||
{
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user