net.RcvThreadShouldSleepForLongRecvErrors
net.RcvThreadShouldSleepForLongRecvErrors
#Overview
name: net.RcvThreadShouldSleepForLongRecvErrors
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether or not the receive thread should sleep for RecvFrom errors which are expected to last a long time. 0 = don\'t sleep, 1 = sleep, 2 = exit receive thread.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of net.RcvThreadShouldSleepForLongRecvErrors is to control the behavior of the receive thread when encountering RecvFrom errors that are expected to last a long time in Unreal Engine’s networking system.
This setting variable is primarily used by the networking subsystem, specifically within the OnlineSubsystemUtils plugin. It’s implemented in the IpNetDriver, which is responsible for handling network communications in Unreal Engine.
The value of this variable is set through a console variable (CVar) system, allowing it to be changed at runtime. It’s defined with a default value of 0, but can be modified through console commands or configuration files.
The associated variable CVarRcvThreadShouldSleepForLongRecvErrors directly interacts with net.RcvThreadShouldSleepForLongRecvErrors. They share the same value and purpose.
Developers must be aware that this variable has three possible settings: 0: The receive thread doesn’t sleep on long RecvFrom errors. 1: The receive thread sleeps on long RecvFrom errors. 2: The receive thread exits on long RecvFrom errors.
Best practices when using this variable include:
- Use it judiciously, as it can affect network performance and responsiveness.
- Test thoroughly with different settings to understand the impact on your specific game or application.
- Consider the nature of your network environment and expected error types when choosing a setting.
- Monitor network performance metrics when adjusting this setting to ensure optimal behavior.
Regarding the associated variable CVarRcvThreadShouldSleepForLongRecvErrors:
Its purpose is identical to net.RcvThreadShouldSleepForLongRecvErrors, serving as the programmatic interface to the console variable.
It’s used within the IpNetDriver’s FReceiveThreadRunnable::Run() function to determine the action to take when long RecvFrom errors occur.
The value is typically retrieved using the GetValueOnAnyThread() method, allowing it to be accessed from any thread safely.
Developers should be aware that changes to this variable will affect the receive thread’s behavior in real-time, potentially impacting network performance.
Best practices include using this variable in conjunction with other network-related settings for comprehensive network behavior control, and logging or telemetry to monitor its effects on network performance.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/IpNetDriver.cpp:94
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarRcvThreadShouldSleepForLongRecvErrors(
TEXT("net.RcvThreadShouldSleepForLongRecvErrors"),
0,
TEXT("Whether or not the receive thread should sleep for RecvFrom errors which are expected to last a long time. ")
TEXT("0 = don't sleep, 1 = sleep, 2 = exit receive thread.")
);
#Associated Variable and Callsites
This variable is associated with another variable named CVarRcvThreadShouldSleepForLongRecvErrors
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/IpNetDriver.cpp:93
Scope: file
Source code excerpt:
TEXT("Time the receive thread will sleep when a waitable error is returned by a socket operation."));
TAutoConsoleVariable<int32> CVarRcvThreadShouldSleepForLongRecvErrors(
TEXT("net.RcvThreadShouldSleepForLongRecvErrors"),
0,
TEXT("Whether or not the receive thread should sleep for RecvFrom errors which are expected to last a long time. ")
TEXT("0 = don't sleep, 1 = sleep, 2 = exit receive thread.")
);
#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/IpNetDriver.cpp:2028
Scope (from outer to inner):
file
function uint32 UIpNetDriver::FReceiveThreadRunnable::Run
Source code excerpt:
const FTimespan Timeout = FTimespan::FromMilliseconds(PollTimeMS);
const float SleepTimeForWaitableErrorsInSec = CVarRcvThreadSleepTimeForWaitableErrorsInSeconds.GetValueOnAnyThread();
const int32 ActionForLongRecvErrors = CVarRcvThreadShouldSleepForLongRecvErrors.GetValueOnAnyThread();
UE_LOG(LogNet, Log, TEXT("UIpNetDriver::FReceiveThreadRunnable::Run starting up."));
// Wait for the Socket to be set
while (bIsRunning && !Socket.IsValid())
{