Move server-related code to server.c
The file server.c already existed, but exposed a low-level API. Make it higher-level, so that scrcpy.c does not handle server details directly.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
// contrary to SDLNet_TCP_Send and SDLNet_TCP_Recv, SDLNet_TCP_Accept is non-blocking
|
||||
// so we need to block before calling it
|
||||
TCPsocket blocking_accept(TCPsocket server_socket) {
|
||||
TCPsocket server_socket_accept(TCPsocket server_socket) {
|
||||
SDLNet_SocketSet set = SDLNet_AllocSocketSet(1);
|
||||
if (!set) {
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not allocate socket set");
|
||||
@@ -19,7 +19,7 @@ TCPsocket blocking_accept(TCPsocket server_socket) {
|
||||
|
||||
// timeout is (2^32-1) milliseconds, this should be sufficient
|
||||
if (SDLNet_CheckSockets(set, -1) != 1) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_SYSTEM, "Could not check socket: %s", SDL_GetError());
|
||||
SDL_LogError(SDL_LOG_CATEGORY_SYSTEM, "Could not check socket");
|
||||
SDLNet_FreeSocketSet(set);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user