|
|
|
@ -4,7 +4,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
// contrary to SDLNet_TCP_Send and SDLNet_TCP_Recv, SDLNet_TCP_Accept is non-blocking
|
|
|
|
// contrary to SDLNet_TCP_Send and SDLNet_TCP_Recv, SDLNet_TCP_Accept is non-blocking
|
|
|
|
// so we need to block before calling it
|
|
|
|
// so we need to block before calling it
|
|
|
|
TCPsocket server_socket_accept(TCPsocket server_socket) {
|
|
|
|
TCPsocket server_socket_accept(TCPsocket server_socket, Uint32 timeout_ms) {
|
|
|
|
SDLNet_SocketSet set = SDLNet_AllocSocketSet(1);
|
|
|
|
SDLNet_SocketSet set = SDLNet_AllocSocketSet(1);
|
|
|
|
if (!set) {
|
|
|
|
if (!set) {
|
|
|
|
SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not allocate socket set");
|
|
|
|
SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not allocate socket set");
|
|
|
|
@ -17,9 +17,8 @@ TCPsocket server_socket_accept(TCPsocket server_socket) {
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// timeout is (2^32-1) milliseconds, this should be sufficient
|
|
|
|
if (SDLNet_CheckSockets(set, timeout_ms) != 1) {
|
|
|
|
if (SDLNet_CheckSockets(set, -1) != 1) {
|
|
|
|
SDL_LogError(SDL_LOG_CATEGORY_SYSTEM, "No connection to accept");
|
|
|
|
SDL_LogError(SDL_LOG_CATEGORY_SYSTEM, "Could not check socket");
|
|
|
|
|
|
|
|
SDLNet_FreeSocketSet(set);
|
|
|
|
SDLNet_FreeSocketSet(set);
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|