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.
This commit is contained in:
@@ -95,9 +95,9 @@ namespace XPC
|
|||||||
// Without this, playback may become choppy due to process blocking
|
// Without this, playback may become choppy due to process blocking
|
||||||
|
|
||||||
// Definitions
|
// Definitions
|
||||||
FD_SET stReadFDS;
|
fd_set stReadFDS;
|
||||||
FD_SET stExceptFDS;
|
fd_set stExceptFDS;
|
||||||
timeval tv;
|
struct timeval timeout;
|
||||||
|
|
||||||
// Setup for Select
|
// Setup for Select
|
||||||
FD_ZERO(&stReadFDS);
|
FD_ZERO(&stReadFDS);
|
||||||
@@ -106,11 +106,11 @@ namespace XPC
|
|||||||
FD_SET(sock, &stExceptFDS);
|
FD_SET(sock, &stExceptFDS);
|
||||||
|
|
||||||
// Set timeout period for select to 0 to poll the socket
|
// Set timeout period for select to 0 to poll the socket
|
||||||
tv.tv_sec = 0;
|
timeout.tv_sec = 0;
|
||||||
tv.tv_usec = 0;
|
timeout.tv_usec = 0;
|
||||||
|
|
||||||
// Select Command
|
// Select Command
|
||||||
int status = select(-1, &stReadFDS, (FD_SET*)0, &stExceptFDS, &tv);
|
int status = select(sock+1, &stReadFDS, NULL, &stExceptFDS, &timeout);
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|||||||
Reference in New Issue
Block a user