ListenEndpoint
ListenEndpoint
#Overview
name: ListenEndpoint
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 10
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of ListenEndpoint is to specify the network endpoint (IP address and port) on which the TCP messaging system should listen for incoming connections. This variable is primarily used in the TCP Messaging plugin of Unreal Engine 5, which is part of the engine’s networking and messaging infrastructure.
The Unreal Engine subsystem that relies on this setting variable is the TCP Messaging plugin, which is part of the broader messaging system. This plugin facilitates network communication between different parts of the engine or between different instances of the engine running on separate machines.
The value of this variable is typically set in the configuration file for the TCP Messaging plugin. It can also be overridden via command-line arguments using the “TcpMessagingListen” parameter.
ListenEndpoint interacts with other variables such as ConnectToEndpoints, which specifies the endpoints to which the system should attempt to establish outgoing connections.
Developers must be aware that:
- The format of the ListenEndpoint should be “IP_ADDRESS:PORT_NUMBER”.
- If the ListenEndpoint is set to an invalid value, the system will default to listening on all available network interfaces (FIPv4Endpoint::Any).
- The actual listening behavior is implemented in the FTcpMessageTransport class.
Best practices when using this variable include:
- Ensure the specified endpoint is accessible and not blocked by firewalls.
- Use a port number that doesn’t conflict with other services.
- Consider security implications when choosing the listening endpoint, especially in production environments.
- Test the connection thoroughly, especially when deploying across different network configurations.
- Use the command-line override option for quick testing or debugging without changing the configuration files.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseEngine.ini:3362, section: [/Script/TcpMessaging.TcpMessagingSettings]
- INI Section:
/Script/TcpMessaging.TcpMessagingSettings
- Raw value: ``
- Is Array:
False
Location: <Workspace>/Engine/Config/Android/AndroidEngine.ini:46, section: [/Script/TcpMessaging.TcpMessagingSettings]
- INI Section:
/Script/TcpMessaging.TcpMessagingSettings
- Raw value:
127.0.0.1:6666
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Messaging/TcpMessaging/Source/TcpMessaging/Private/Settings/TcpMessagingSettings.h:43
Scope (from outer to inner):
file
class class UTcpMessagingSettings : public UObject
Source code excerpt:
*/
UPROPERTY(config, EditAnywhere, Category=Transport)
FString ListenEndpoint;
/**
* The IP endpoints to try to establish outgoing connection to.
*
* Use this setting to connect to a remote peer.
* The format is IP_ADDRESS:PORT_NUMBER.
#Loc: <Workspace>/Engine/Plugins/Messaging/TcpMessaging/Source/TcpMessaging/Private/TcpMessagingModule.cpp:193
Scope (from outer to inner):
file
class class FTcpMessagingModule : public FSelfRegisteringExec , public ITcpMessagingModule
function void InitializeBridge
Source code excerpt:
bool ResaveSettings = false;
FIPv4Endpoint ListenEndpoint;
TArray<FIPv4Endpoint> ConnectToEndpoints;
FString ListenEndpointString = Settings->GetListenEndpoint();
if (!FIPv4Endpoint::Parse(ListenEndpointString, ListenEndpoint))
{
if (!ListenEndpointString.IsEmpty())
{
UE_LOG(LogTcpMessaging, Warning, TEXT("Invalid setting for ListenEndpoint '%s', listening disabled"), *ListenEndpointString);
}
ListenEndpoint = FIPv4Endpoint::Any;
}
TArray<FString> ConnectToEndpointStrings;
Settings->GetConnectToEndpoints(ConnectToEndpointStrings);
for (FString& ConnectToEndpointString : ConnectToEndpointStrings)
#Loc: <Workspace>/Engine/Plugins/Messaging/TcpMessaging/Source/TcpMessaging/Private/TcpMessagingModule.cpp:229
Scope (from outer to inner):
file
class class FTcpMessagingModule : public FSelfRegisteringExec , public ITcpMessagingModule
function void InitializeBridge
Source code excerpt:
Status += FString::Printf(TEXT(" for %d outgoing connections"), ConnectToEndpoints.Num());
}
if (ListenEndpoint != FIPv4Endpoint::Any)
{
Status += TEXT(", listening on ");
Status += ListenEndpoint.ToText().ToString();
}
UE_LOG(LogTcpMessaging, Log, TEXT("%s"), *Status);
TSharedRef<FTcpMessageTransport, ESPMode::ThreadSafe> Transport = MakeShareable(new FTcpMessageTransport(ListenEndpoint, ConnectToEndpoints, Settings->GetConnectionRetryDelay(), Settings->GetConnectionRetryPeriod()));
// Safe weak pointer for adding/removing connections
MessageTransportPtr = Transport;
MessageBridge = FMessageBridgeBuilder().UsingTransport(Transport);
}
#Loc: <Workspace>/Engine/Plugins/Messaging/TcpMessaging/Source/TcpMessaging/Private/TcpMessagingModule.cpp:354
Scope (from outer to inner):
file
function FString UTcpMessagingSettings::GetListenEndpoint
Source code excerpt:
FString UTcpMessagingSettings::GetListenEndpoint() const
{
FString HostString = ListenEndpoint;
// Read command line override
FParse::Value(FCommandLine::Get(), TEXT("TcpMessagingListen="), HostString);
return HostString;
}
#Loc: <Workspace>/Engine/Plugins/Messaging/TcpMessaging/Source/TcpMessaging/Private/Transport/TcpMessageTransport.cpp:16
Scope (from outer to inner):
file
function FTcpMessageTransport::FTcpMessageTransport
Source code excerpt:
FTcpMessageTransport::FTcpMessageTransport(const FIPv4Endpoint& InListenEndpoint, const TArray<FIPv4Endpoint>& InConnectToEndpoints, int32 InConnectionRetryDelay, int32 InConnectionRetryPeriod)
: ListenEndpoint(InListenEndpoint)
, ConnectToEndpoints(InConnectToEndpoints)
, ConnectionRetryDelay(InConnectionRetryDelay)
, ConnectionRetryPeriod(InConnectionRetryPeriod)
, bStopping(false)
, SocketSubsystem(ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM))
, Listener(nullptr)
#Loc: <Workspace>/Engine/Plugins/Messaging/TcpMessaging/Source/TcpMessaging/Private/Transport/TcpMessageTransport.cpp:48
Scope (from outer to inner):
file
function bool FTcpMessageTransport::StartTransport
Source code excerpt:
TransportHandler = &Handler;
if (ListenEndpoint != FIPv4Endpoint::Any)
{
Listener = new FTcpListener(ListenEndpoint);
Listener->OnConnectionAccepted().BindRaw(this, &FTcpMessageTransport::HandleListenerConnectionAccepted);
}
// outgoing connections
for (auto& ConnectToEndPoint : ConnectToEndpoints)
{
#Loc: <Workspace>/Engine/Plugins/Messaging/TcpMessaging/Source/TcpMessaging/Private/Transport/TcpMessageTransport.h:92
Scope (from outer to inner):
file
class class FTcpMessageTransport : FRunnable , public IMessageTransport
Source code excerpt:
/** Current settings */
FIPv4Endpoint ListenEndpoint;
TArray<FIPv4Endpoint> ConnectToEndpoints;
int32 ConnectionRetryDelay;
int32 ConnectionRetryPeriod;
/** For the thread */
bool bStopping;
#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/IOS/TcpConsoleListener.cpp:12
Scope (from outer to inner):
file
function TcpConsoleListener::TcpConsoleListener
Source code excerpt:
TcpConsoleListener::TcpConsoleListener(const FIPv4Endpoint& InListenEndpoint)
: ListenEndpoint(InListenEndpoint)
, bStopping(false)
, Listener(nullptr)
{
UE_LOG(LogTemp, Display, TEXT("Initializing TCPConsoleListener."));
Thread = FRunnableThread::Create(this, TEXT("TcpConsoleListener"), 128 * 1024, TPri_Normal);
}
#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/IOS/TcpConsoleListener.cpp:53
Scope (from outer to inner):
file
function bool TcpConsoleListener::Init
Source code excerpt:
bool TcpConsoleListener::Init()
{
Listener = new FTcpListener(ListenEndpoint);
Listener->OnConnectionAccepted().BindRaw(this, &TcpConsoleListener::HandleListenerConnectionAccepted);
return true;
}
#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/IOS/TcpConsoleListener.h:44
Scope (from outer to inner):
file
class class TcpConsoleListener : FRunnable
Source code excerpt:
/** Current settings */
FIPv4Endpoint ListenEndpoint;
/** For the thread */
bool bStopping;
/** Holds the local listener for incoming tunnel connections. */
FTcpListener* Listener;