From 4241599ad772268831ef652de753b2a5c2711207 Mon Sep 17 00:00:00 2001 From: Norman Princen Date: Tue, 12 May 2020 18:58:29 -0700 Subject: [PATCH] Minimize sendUDP and readUDP Socket Timeout Delays sendUDP and readUDP 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. --- C/src/xplaneConnect.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/C/src/xplaneConnect.c b/C/src/xplaneConnect.c index 11cc6a8..208ed7f 100755 --- a/C/src/xplaneConnect.c +++ b/C/src/xplaneConnect.c @@ -195,9 +195,9 @@ int readUDP(XPCSocket sock, char buffer[], int len) // Without this, playback may become choppy due to process blocking // Definitions - FD_SET stReadFDS; - FD_SET stExceptFDS; - struct timeval tv; + fd_set stReadFDS; + fd_set stExceptFDS; + struct timeval timeout; // Setup for Select FD_ZERO(&stReadFDS); @@ -207,11 +207,11 @@ int readUDP(XPCSocket sock, char buffer[], int len) // Set timeout period for select to 0.05 sec = 50 milliseconds = 50,000 microseconds (0 makes it polling) // TO DO - This could be set to 0 if a message handling system were implemented, like in the plugin. - tv.tv_sec = 0; - tv.tv_usec = 50000; + timeout.tv_sec = 0; + timeout.tv_usec = 50000; // Select Command - int status = select(-1, &stReadFDS, (FD_SET*)0, &stExceptFDS, &tv); + int status = select(sock.sock+1, &stReadFDS, NULL, &stExceptFDS, &timeout); if (status < 0) { printError("readUDP", "Select command error");