From 1f78a23351faebc85fe7f82ddcd92a329852792a Mon Sep 17 00:00:00 2001 From: Norman Princen Date: Tue, 12 May 2020 19:06:28 -0700 Subject: [PATCH] Minimize SendTo and Read Socket Timeout Delays SendTo and Read were using longer than necessary socket timeouts that may add to process time delay and stuttering. They were also using different values between Window and Linux/Mac. The timeouts are now standardized for all versions and coded in the same manner as the xplaneConnect.c functions. --- xpcPlugin/UDPSocket.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/xpcPlugin/UDPSocket.cpp b/xpcPlugin/UDPSocket.cpp index 9defeb0..5925ebe 100644 --- a/xpcPlugin/UDPSocket.cpp +++ b/xpcPlugin/UDPSocket.cpp @@ -95,9 +95,9 @@ namespace XPC // Without this, playback may become choppy due to process blocking // Definitions - FD_SET stReadFDS; - FD_SET stExceptFDS; - timeval tv; + fd_set stReadFDS; + fd_set stExceptFDS; + struct timeval timeout; // Setup for Select FD_ZERO(&stReadFDS); @@ -106,11 +106,11 @@ namespace XPC FD_SET(sock, &stExceptFDS); // Set timeout period for select to 0 to poll the socket - tv.tv_sec = 0; - tv.tv_usec = 0; + timeout.tv_sec = 0; + timeout.tv_usec = 0; // Select Command - int status = select(-1, &stReadFDS, (FD_SET*)0, &stExceptFDS, &tv); + int status = select(sock+1, &stReadFDS, NULL, &stExceptFDS, &timeout); if (status < 0) { #ifdef _WIN32