UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
IPAddressAsyncResolve.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Async/AsyncWork.h"
6#include "IPAddress.h"
7#include "Stats/Stats.h"
8
14{
15protected:
18 {
19 }
20
21public:
23 virtual ~FResolveInfo()
24 {
25 }
26
32 virtual bool IsComplete() const = 0;
33
39 virtual int32 GetErrorCode() const = 0;
40
46 virtual const FInternetAddr& GetResolvedAddress() const = 0;
47};
48
51{
52protected:
55
58
59public:
66
67 // FResolveInfo interface
68
74 virtual bool IsComplete() const
75 {
76 return true;
77 }
78
84 virtual int32 GetErrorCode() const
85 {
86 return 0;
87 }
88
94 virtual const FInternetAddr& GetResolvedAddress() const
95 {
96 return *Addr;
97 }
98};
99
100//
101// Class for creating a background thread to resolve a host.
102//
104 public FResolveInfo
105{
106 //
107 // A simple wrapper task that calls back to FResolveInfoAsync to do the actual work
108 //
109 class FResolveInfoAsyncWorker
110 {
111 public:
114
118 FResolveInfoAsyncWorker(FResolveInfoAsync* InParent)
120 {
121 }
122
124 void DoWork()
125 {
126 Parent->DoWork();
127 }
128
129 inline TStatId GetStatId() const
130 {
132 }
133
135 bool CanAbandon()
136 {
137 return true;
138 }
139
141 void Abandon()
142 {
143 FPlatformAtomics::InterlockedExchange(&Parent->bShouldAbandon, true);
144 }
145 };
146 // Variables.
148 ANSICHAR HostName[256];
150 int32 ErrorCode;
152 volatile int32 bShouldAbandon;
155
156public:
163
168 {
169 check(AsyncTask.GetTask().Parent == this); // need to make sure these aren't memcpy'd around after construction
170 AsyncTask.StartBackgroundTask();
171 }
172
176 void DoWork();
177
178 // FResolveInfo interface
179
185 virtual bool IsComplete() const
186 {
187 // this semantically const, but IsDone syncs the async task, and that causes writes
188 return const_cast<FAsyncTask<FResolveInfoAsyncWorker> &>(AsyncTask).IsDone();
189 }
190
196 virtual int32 GetErrorCode() const
197 {
198 return ErrorCode;
199 }
200
206 virtual const FInternetAddr& GetResolvedAddress() const
207 {
208 return *Addr;
209 }
210};
#define check(expr)
Definition AssertionMacros.h:314
void AsyncTask(ENamedThreads::Type Thread, TUniqueFunction< void()> Function)
Definition Async.cpp:54
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::ANSICHAR ANSICHAR
An ANSI character. Normally a signed type.
Definition Platform.h:1131
#define RETURN_QUICK_DECLARE_CYCLE_STAT(StatId, GroupId)
Definition Stats.h:655
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition AsyncWork.h:585
Definition IPAddress.h:22
Definition IPAddressAsyncResolve.h:105
virtual bool IsComplete() const
Definition IPAddressAsyncResolve.h:185
void DoWork()
Definition IPAddress.cpp:39
void StartAsyncTask()
Definition IPAddressAsyncResolve.h:167
virtual const FInternetAddr & GetResolvedAddress() const
Definition IPAddressAsyncResolve.h:206
virtual int32 GetErrorCode() const
Definition IPAddressAsyncResolve.h:196
Definition IPAddressAsyncResolve.h:51
virtual const FInternetAddr & GetResolvedAddress() const
Definition IPAddressAsyncResolve.h:94
virtual int32 GetErrorCode() const
Definition IPAddressAsyncResolve.h:84
TSharedPtr< FInternetAddr > Addr
Definition IPAddressAsyncResolve.h:54
virtual bool IsComplete() const
Definition IPAddressAsyncResolve.h:74
FResolveInfoCached()
Definition IPAddressAsyncResolve.h:57
Definition IPAddressAsyncResolve.h:14
virtual ~FResolveInfo()
Definition IPAddressAsyncResolve.h:23
virtual int32 GetErrorCode() const =0
virtual const FInternetAddr & GetResolvedAddress() const =0
FResolveInfo()
Definition IPAddressAsyncResolve.h:17
virtual bool IsComplete() const =0
Definition SharedPointer.h:692
Definition LightweightStats.h:416