UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
IPv4Endpoint.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/Array.h"
7#include "CoreMinimal.h"
8#include "HAL/Platform.h"
9#include "HAL/PlatformCrt.h"
10#include "IPAddress.h"
15#include "SocketSubsystem.h"
17#include "Templates/TypeHash.h"
18
27{
30
33
34public:
35
38
49
58 {
59 check(InternetAddr.IsValid());
60
63 InternetAddr->GetPort(OutPort);
64 Port = static_cast<uint16>(OutPort);
65 }
66
67public:
68
75 bool operator==(const FIPv4Endpoint& Other) const
76 {
77 return ((Address == Other.Address) && (Port == Other.Port));
78 }
79
86 bool operator!=(const FIPv4Endpoint& Other) const
87 {
88 return ((Address != Other.Address) || (Port != Other.Port));
89 }
90
98 friend FArchive& operator<<(FArchive& Ar, FIPv4Endpoint& Endpoint)
99 {
100 return Ar << Endpoint.Address << Endpoint.Port;
101 }
102
103public:
104
113 {
114 check(CachedSocketSubsystem != nullptr && "Networking module not loaded and initialized");
115
117 {
119 InternetAddr->SetPort(Port);
120 }
121
122 return InternetAddr;
123 }
124
133 {
134 check(CachedSocketSubsystem != nullptr && "Networking module not loaded and initialized");
135
137 {
140 RawAddress.Add(Address.B);
141 RawAddress.Add(Address.C);
142 RawAddress.Add(Address.D);
143 InternetAddr->SetRawIp(RawAddress);
144 InternetAddr->SetPort(Port);
145 }
146
147 return InternetAddr;
148 }
149
156 NETWORKING_API FString ToString() const;
157
164 FText ToText() const
165 {
166 return FText::FromString(ToString());
167 }
168
169public:
170
177 friend uint32 GetTypeHash(const FIPv4Endpoint& Endpoint)
178 {
179 return HashCombine(GetTypeHash(Endpoint.Address), GetTypeHash(Endpoint.Port));
180 }
181
182public:
183
185 static NETWORKING_API void Initialize();
186
195 static NETWORKING_API bool Parse(const FString& EndpointString, FIPv4Endpoint& OutEndpoint);
196
205
206public:
207
210
211private:
212
214 static NETWORKING_API ISocketSubsystem* CachedSocketSubsystem;
215};
#define check(expr)
Definition AssertionMacros.h:314
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
constexpr uint32 HashCombine(uint32 A, uint32 C)
Definition TypeHash.h:36
uint16_t uint16
Definition binka_ue_file_header.h:7
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Archive.h:1208
virtual void SetIp(uint32 InAddr)=0
Definition Text.h:385
static CORE_API FText FromString(const ANSICHAR *String)
Definition Text.cpp:1081
Definition SocketSubsystem.h:58
virtual TSharedRef< FInternetAddr > CreateInternetAddr(uint32 Address, uint32 Port=0)
Definition SocketSubsystem.h:317
Definition Array.h:670
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add(ElementType &&Item)
Definition Array.h:2696
Definition SharedPointer.h:692
Definition SharedPointer.h:153
Definition IPv4Address.h:16
uint8 A
Definition IPv4Address.h:30
uint8 B
Definition IPv4Address.h:30
uint32 Value
Definition IPv4Address.h:35
uint8 D
Definition IPv4Address.h:30
uint8 C
Definition IPv4Address.h:30
Definition IPv4Endpoint.h:27
static NETWORKING_API bool FromHostAndPort(const FString &HostAndPortString, FIPv4Endpoint &OutEndpoint)
Definition IPv4Endpoint.cpp:56
static NETWORKING_API bool Parse(const FString &EndpointString, FIPv4Endpoint &OutEndpoint)
Definition IPv4Endpoint.cpp:32
TSharedRef< FInternetAddr > ToInternetAddr() const
Definition IPv4Endpoint.h:112
bool operator!=(const FIPv4Endpoint &Other) const
Definition IPv4Endpoint.h:86
bool operator==(const FIPv4Endpoint &Other) const
Definition IPv4Endpoint.h:75
uint16 Port
Definition IPv4Endpoint.h:32
FIPv4Endpoint()
Definition IPv4Endpoint.h:37
FIPv4Address Address
Definition IPv4Endpoint.h:29
static NETWORKING_API const FIPv4Endpoint Any
Definition IPv4Endpoint.h:209
static NETWORKING_API void Initialize()
Definition IPv4Endpoint.cpp:26
FIPv4Endpoint(const TSharedPtr< FInternetAddr > &InternetAddr)
Definition IPv4Endpoint.h:57
friend FArchive & operator<<(FArchive &Ar, FIPv4Endpoint &Endpoint)
Definition IPv4Endpoint.h:98
FIPv4Endpoint(const FIPv4Address &InAddress, uint16 InPort)
Definition IPv4Endpoint.h:45
TSharedRef< FInternetAddr > ToInternetAddrIPV4() const
Definition IPv4Endpoint.h:132
friend uint32 GetTypeHash(const FIPv4Endpoint &Endpoint)
Definition IPv4Endpoint.h:177
NETWORKING_API FString ToString() const
Definition IPv4Endpoint.cpp:17
FText ToText() const
Definition IPv4Endpoint.h:164