bIsUsingP2PSockets
bIsUsingP2PSockets
#Overview
name: bIsUsingP2PSockets
The value of this variable can be defined or overridden in .ini config files. 2
.ini config files referencing this setting variable.
It is referenced in 7
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of bIsUsingP2PSockets is to determine whether the game should use peer-to-peer (P2P) sockets for network communication in the Epic Online Services (EOS) subsystem, rather than traditional IP-based sockets.
This setting variable is primarily used by the Online Subsystem EOS and Socket Subsystem EOS plugins in Unreal Engine 5. These plugins are responsible for handling online functionality and network communication using Epic’s online services.
The value of this variable is typically set in the engine configuration files (GEngineIni). It’s first checked in the “/Script/OnlineSubsystemEOS.NetDriverEOS” section, and if not found, it falls back to the “/Script/SocketSubsystemEOS.NetDriverEOSBase” section.
This variable interacts closely with other networking-related variables and functions, particularly those involving session creation, connection initialization, and socket management.
Developers must be aware that:
- This setting affects how network connections are established and managed.
- It can influence the behavior of dedicated servers and client connections.
- When enabled, it may require additional setup for proper P2P communication.
Best practices when using this variable include:
- Ensuring it’s correctly set in the appropriate configuration files.
- Testing thoroughly in both P2P and traditional networking scenarios.
- Considering the implications on cross-platform play and different network environments.
- Coordinating its use with other EOS-related settings for consistent behavior.
#Setting Variables
#References In INI files
Location: <Workspace>/Projects/Lyra/Config/Custom/EOS/DefaultEngine.ini:51, section: [/Script/SocketSubsystemEOS.NetDriverEOSBase]
- INI Section:
/Script/SocketSubsystemEOS.NetDriverEOSBase
- Raw value:
true
- Is Array:
False
Location: <Workspace>/Projects/Lyra/Config/Custom/SteamEOS/DefaultEngine.ini:56, section: [/Script/SocketSubsystemEOS.NetDriverEOSBase]
- INI Section:
/Script/SocketSubsystemEOS.NetDriverEOSBase
- Raw value:
true
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemEOS/Source/OnlineSubsystemEOS/Private/OnlineSessionEOS.cpp:482
Scope (from outer to inner):
file
function void FOnlineSessionEOS::Init
Source code excerpt:
RegisterLobbyNotifications();
bIsUsingP2PSockets = false;
if (!GConfig->GetBool(TEXT("/Script/OnlineSubsystemEOS.NetDriverEOS"), TEXT("bIsUsingP2PSockets"), bIsUsingP2PSockets, GEngineIni))
{
// Fallback to base location
GConfig->GetBool(TEXT("/Script/SocketSubsystemEOS.NetDriverEOSBase"), TEXT("bIsUsingP2PSockets"), bIsUsingP2PSockets, GEngineIni);
}
}
/**
* Searches the named session array for the specified session
*
#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemEOS/Source/OnlineSubsystemEOS/Private/OnlineSessionEOS.cpp:1507
Scope (from outer to inner):
file
function uint32 FOnlineSessionEOS::CreateEOSSession
Source code excerpt:
FString HostAddr;
// If we are using local IPs in a dedicated server, or if we are using p2p sockets, then we need to add a custom URL for connecting
if (!IsRunningDedicatedServer() && bIsUsingP2PSockets)
{
// Because some platforms remap ports, we will use the ID of the name of the net driver to be our port instead
FName NetDriverName = GetDefault<UNetDriverEOS>()->NetDriverName;
FInternetAddrEOS TempAddr(LexToString(Options.LocalUserId), NetDriverName.ToString(), GetTypeHash(NetDriverName.ToString()));
HostAddr = TempAddr.ToString(true);
}
#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemEOS/Source/OnlineSubsystemEOS/Private/OnlineSessionEOS.h:340
Scope (from outer to inner):
file
class class FOnlineSessionEOS : public IOnlineSession , public TSharedFromThis<FOnlineSessionEOS, ESPMode::ThreadSafe>
Source code excerpt:
FCallbackBase* JoinSessionAcceptedCallback;
bool bIsUsingP2PSockets;
};
typedef TSharedPtr<FOnlineSessionEOS, ESPMode::ThreadSafe> FOnlineSessionEOSPtr;
typedef TWeakPtr<FOnlineSessionEOS, ESPMode::ThreadSafe> FOnlineSessionEOSWeakPtr;
#endif
#Loc: <Workspace>/Engine/Plugins/Online/SocketSubsystemEOS/Source/SocketSubsystemEOS/Private/NetConnectionEOS.cpp:15
Scope (from outer to inner):
file
function void UNetConnectionEOS::InitLocalConnection
Source code excerpt:
void UNetConnectionEOS::InitLocalConnection(UNetDriver* InDriver, FSocket* InSocket, const FURL& InURL, EConnectionState InState, int32 InMaxPacket, int32 InPacketOverhead)
{
bIsPassthrough = !static_cast<UNetDriverEOSBase*>(InDriver)->bIsUsingP2PSockets || !InURL.Host.StartsWith(EOS_CONNECTION_URL_PREFIX, ESearchCase::IgnoreCase);
bHasP2PSession = !bIsPassthrough;
if (bHasP2PSession)
{
DisableAddressResolution();
}
#Loc: <Workspace>/Engine/Plugins/Online/SocketSubsystemEOS/Source/SocketSubsystemEOS/Private/NetDriverEOSBase.cpp:86
Scope (from outer to inner):
file
function bool UNetDriverEOSBase::InitConnect
Source code excerpt:
bool UNetDriverEOSBase::InitConnect(FNetworkNotify* InNotify, const FURL& ConnectURL, FString& Error)
{
if (!bIsUsingP2PSockets || !IsAvailable() || !ConnectURL.Host.StartsWith(EOS_CONNECTION_URL_PREFIX, ESearchCase::IgnoreCase))
{
UE_LOG(LogTemp, Verbose, TEXT("Connecting using IPNetDriver passthrough. ConnectUrl = (%s)"), *ConnectURL.ToString());
bIsPassthrough = true;
return Super::InitConnect(InNotify, ConnectURL, Error);
}
#Loc: <Workspace>/Engine/Plugins/Online/SocketSubsystemEOS/Source/SocketSubsystemEOS/Private/NetDriverEOSBase.cpp:143
Scope (from outer to inner):
file
function bool UNetDriverEOSBase::InitListen
Source code excerpt:
bool UNetDriverEOSBase::InitListen(FNetworkNotify* InNotify, FURL& LocalURL, bool bReuseAddressAndPort, FString& Error)
{
if (!bIsUsingP2PSockets || !IsAvailable() || LocalURL.HasOption(TEXT("bIsLanMatch")) || LocalURL.HasOption(TEXT("bUseIPSockets")))
{
UE_LOG(LogTemp, Verbose, TEXT("Init as IPNetDriver listen server. LocalURL = (%s)"), *LocalURL.ToString());
bIsPassthrough = true;
return Super::InitListen(InNotify, LocalURL, bReuseAddressAndPort, Error);
}
#Loc: <Workspace>/Engine/Plugins/Online/SocketSubsystemEOS/Source/SocketSubsystemEOS/Public/NetDriverEOSBase.h:32
Scope (from outer to inner):
file
class class UNetDriverEOSBase : public UIpNetDriver
Source code excerpt:
UPROPERTY(Config)
bool bIsUsingP2PSockets;
};