net.DisableIPv6
net.DisableIPv6
#Overview
name: net.DisableIPv6
The value of this variable can be defined or overridden in .ini config files. 1
.ini config file referencing this setting variable.
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If true, IPv6 will not resolve and its usage will be avoided when possible
It is referenced in 8
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of net.DisableIPv6 is to control the usage of IPv6 in the Unreal Engine’s networking subsystem. This setting variable is used to disable IPv6 functionality when set to a non-zero value, effectively forcing the engine to use IPv4 for network communications.
This setting variable is primarily used by the Sockets subsystem in Unreal Engine 5. It is referenced in various platform-specific implementations of the socket subsystem, including BSD, Mac, Unix, and Windows.
The value of this variable is set through a console variable (CVarDisableIPv6) defined in the BSDSockets implementation file. It is initialized with a default value of 1, meaning IPv6 is disabled by default.
The associated variable CVarDisableIPv6 directly interacts with net.DisableIPv6. They share the same value and purpose.
Developers must be aware that:
- By default, IPv6 is disabled (value is 1).
- Changing this value affects the entire networking stack of the engine.
- The actual behavior may depend on the platform’s support for IPv6 (PLATFORM_HAS_BSD_IPV6_SOCKETS).
Best practices when using this variable include:
- Only enable IPv6 (by setting to 0) if your game explicitly requires IPv6 support.
- Test thoroughly on all target platforms when changing this value, as networking behavior may differ.
- Consider the implications on cross-platform play if some platforms don’t support IPv6.
Regarding the associated variable CVarDisableIPv6:
- It is an auto console variable of type int32.
- It is used throughout the socket subsystem to check whether IPv6 should be disabled.
- When using this variable in code, it’s recommended to use the GetValueOnAnyThread() method to retrieve its current value.
- Developers should be cautious about changing its value at runtime, as it may affect ongoing network operations.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/IOS/BaseIOSEngine.ini:100, section: [SystemSettings]
- INI Section:
SystemSettings
- Raw value:
0
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Sockets/Private/BSDSockets/SocketSubsystemBSD.cpp:10
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarDisableIPv6(
TEXT("net.DisableIPv6"),
1,
TEXT("If true, IPv6 will not resolve and its usage will be avoided when possible"));
FSocketBSD* FSocketSubsystemBSD::InternalBSDSocketFactory(SOCKET Socket, ESocketType SocketType, const FString& SocketDescription, const FName& SocketProtocol)
{
// return a new socket object
#Associated Variable and Callsites
This variable is associated with another variable named CVarDisableIPv6
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Sockets/Private/BSDSockets/SocketSubsystemBSD.cpp:9
Scope: file
Source code excerpt:
#include <errno.h>
TAutoConsoleVariable<int32> CVarDisableIPv6(
TEXT("net.DisableIPv6"),
1,
TEXT("If true, IPv6 will not resolve and its usage will be avoided when possible"));
FSocketBSD* FSocketSubsystemBSD::InternalBSDSocketFactory(SOCKET Socket, ESocketType SocketType, const FString& SocketDescription, const FName& SocketProtocol)
{
#Loc: <Workspace>/Engine/Source/Runtime/Sockets/Private/BSDSockets/SocketSubsystemBSD.cpp:91
Scope (from outer to inner):
file
function FAddressInfoResult FSocketSubsystemBSD::GetAddressInfo
Source code excerpt:
// Make sure we filter out IPv6 if the platform is not officially supported
const bool bCanUseIPv6 = (CVarDisableIPv6.GetValueOnAnyThread() == 0 && PLATFORM_HAS_BSD_IPV6_SOCKETS);
// Determine if we can save time with numericserv
if (ServiceName != nullptr && FString(ServiceName).IsNumeric())
{
QueryFlags |= EAddressInfoFlags::NoResolveService;
}
#Loc: <Workspace>/Engine/Source/Runtime/Sockets/Private/BSDSockets/SocketSubsystemBSD.cpp:540
Scope (from outer to inner):
file
function bool FSocketSubsystemBSD::GetLocalHostAddrViaConnect
Source code excerpt:
bool bReturnValue = false;
const bool bDisableIPv6 = CVarDisableIPv6.GetValueOnAnyThread() == 1;
TSharedRef<FInternetAddr> ConnectAddr = bDisableIPv6 ? CreateInternetAddr(FNetworkProtocolTypes::IPv4) : CreateInternetAddr();
bool bIsValid = false;
// any IP will do, doesn't even need to be reachable
if (ConnectAddr->GetProtocolType() == FNetworkProtocolTypes::IPv6)
#Loc: <Workspace>/Engine/Source/Runtime/Sockets/Private/BSDSockets/SocketSubsystemBSD.h:12
Scope: file
Source code excerpt:
class FSocketBSD;
extern TAutoConsoleVariable<int32> CVarDisableIPv6;
#include "SocketSubsystemBSDPrivate.h"
/**
* Standard BSD specific socket subsystem implementation
*/
#Loc: <Workspace>/Engine/Source/Runtime/Sockets/Private/Mac/SocketSubsystemMac.cpp:87
Scope (from outer to inner):
file
function bool FSocketSubsystemMac::GetLocalAdapterAddresses
Source code excerpt:
int InterfaceQueryRet = getifaddrs(&Interfaces);
UE_LOG(LogSockets, Verbose, TEXT("Querying net interfaces returned: %d"), InterfaceQueryRet);
const bool bDisableIPv6 = CVarDisableIPv6.GetValueOnAnyThread() == 1;
if (InterfaceQueryRet == 0)
{
// Loop through linked list of interfaces
for (ifaddrs* Travel = Interfaces; Travel != NULL; Travel = Travel->ifa_next)
{
// Skip over empty data sets.
#Loc: <Workspace>/Engine/Source/Runtime/Sockets/Private/Unix/SocketSubsystemUnix.cpp:112
Scope (from outer to inner):
file
function bool FSocketSubsystemUnix::GetLocalAdapterAddresses
Source code excerpt:
int InterfaceQueryRet = getifaddrs(&Interfaces);
UE_LOG(LogSockets, Verbose, TEXT("Querying net interfaces returned: %d"), InterfaceQueryRet);
const bool bDisableIPv6 = CVarDisableIPv6.GetValueOnAnyThread() == 1;
if (InterfaceQueryRet == 0)
{
// Loop through linked list of interfaces
for (ifaddrs* Travel = Interfaces; Travel != NULL; Travel = Travel->ifa_next)
{
// Skip over empty data sets.
#Loc: <Workspace>/Engine/Source/Runtime/Sockets/Private/Windows/SocketSubsystemWindows.cpp:137
Scope (from outer to inner):
file
function bool FSocketSubsystemWindows::GetLocalAdapterAddresses
Source code excerpt:
ULONG Result;
ULONG Size = 0;
ULONG Family = (PLATFORM_HAS_BSD_IPV6_SOCKETS && CVarDisableIPv6.GetValueOnAnyThread() == 0) ? AF_UNSPEC : AF_INET;
// determine the required size of the address list buffer
Result = GetAdaptersAddresses(Family, Flags, NULL, NULL, &Size);
if (Result != ERROR_BUFFER_OVERFLOW)
{