UNetworkUtils
UCLASS()
class AR51SDK_API UNetworkUtils : public UObject
Inherits: UObject (Unreal Engine)
A stateless utility class of static networking helpers. You never instantiate it — call its functions directly (UNetworkUtils::GetLocalIp()), or use the pure/callable Blueprint nodes. Handy for advertising the device's local IP and for picking a free port before opening a connection or stream. Defined in Public/Utilities/NetworkUtils.h.
This area exposes platform/networking helpers only — no positions, lengths, or angles — so the AR 51 (meters) ↔ Unreal (cm/degrees) unit conversion does not apply here.
Method summary
Static
| Method | Returns | |
|---|---|---|
GetLocalIp | FString | BlueprintPure |
GetAvailablePort | bool | BlueprintCallable |
GetLocalAddresses | TArray<TSharedPtr<FInternetAddr>> | C++ only |
→ Full descriptions in Method details below.
Method details
GetLocalIp
static FString GetLocalIp();
The device's local IP address as a string, or an empty string if no valid address can be obtained. Exposed as a pure Blueprint node (no exec pins).
"x.x.x.x", or "" if none is availableGetAvailablePort
static bool GetAvailablePort(int32 StartPort, const TSet<int32>& ExcludedPorts, int32& OutPort);
Scans upward from StartPort for the first free network port that is not in ExcludedPorts, writes it to OutPort, and returns true. On failure OutPort is set to -1 and the function returns false. Use it to pick a free port before opening a connection or stream.
-1 on failuretrue and a valid OutPort if a free port was found; false and OutPort == -1 otherwise// Reserve a free port at/above 50000, skipping a couple we plan to use elsewhere.
int32 Port = -1;
const TSet<int32> Reserved = { 50051, 50052 };
if (UNetworkUtils::GetAvailablePort(50000, Reserved, Port))
{
const FString Endpoint = FString::Printf(TEXT("%s:%d"), *UNetworkUtils::GetLocalIp(), Port);
UE_LOG(LogTemp, Log, TEXT("Listening on %s"), *Endpoint);
}
else
{
UE_LOG(LogTemp, Warning, TEXT("No free port available from 50000"));
}
GetLocalAddresses
static TArray<TSharedPtr<FInternetAddr>> GetLocalAddresses();
All local network addresses for the device, or an empty array if the socket subsystem is unavailable or none are found. This is the lower-level counterpart to GetLocalIp — use it from C++ when you need the full address list rather than a single string. Not a UFUNCTION, so it is not available in Blueprint.
See also
AAR51SDK— connection entry point; itsServiceLocalIPAddress/ServicesPortproperties pair with these helpersUnrealThread— the other public C++ utility in this area (game-thread dispatcher)- Utilities & Platform — platform enum, networking, threading, logging, singletons
- Class index — all Unreal SDK types