Files
UnrealEngineUWP/Engine/Source/Runtime/Sockets/Private/IPAddress.cpp
henrik karlsson b985fbd1b1 Removed lots of includes in high traffic headers in order to reduce compile times. Headers are still included if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_2 is set to 1
List of highlights
* PlayerController - Removed ForceFeedback and and OnlineReplStructs
* Class - Removed Package.h
* World - Pawn, Blueprint and GameInstance
* Actor - CoreNet, HitResult and ActorDatalayer
* EngineBaseTypes - TaskGraphInterface
* AssetManager - AssetData
* Scene/Child/ActorComponent - CoreNet
* AnimInstance - AttributesRuntime, Skeleton, AnimCurveTypes, AnimMontage, BonePose
* BulkData - IoDispatcher
* AssetData - IoDispatcher, LinkerLoad
* SecureHash - AsyncWork
* CanvasTypes - UnrealEngine, StaticMeshResources
* IpAddress - AsyncWork, Stats

#preflight 6363717ece676ae8688f5d8c
#rb none

[CL 22968258 by henrik karlsson in ue5-main branch]
2022-11-03 17:56:44 -04:00

78 lines
1.8 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "IPAddress.h"
#include "IPAddressAsyncResolve.h"
#include "SocketSubsystem.h"
#include "AddressInfoTypes.h"
void FInternetAddr::DumpAddrData() const
{
UE_LOG(LogSockets, Log, TEXT("Dumping Addr Data : Addr = %s Protocol = %s Port = %i PlatformPort = %i"), *ToString(true), *GetProtocolType().ToString(), GetPort(), GetPlatformPort());
}
/**
* Sets the address to return to the caller
*
* @param InAddr the address that is being cached
*/
FResolveInfoCached::FResolveInfoCached(const FInternetAddr& InAddr)
{
Addr = InAddr.Clone();
}
/**
* Copies the host name for async resolution
*
* @param InHostName the host name to resolve
*/
FResolveInfoAsync::FResolveInfoAsync(const ANSICHAR* InHostName) :
ErrorCode(SE_NO_ERROR),
bShouldAbandon(false),
AsyncTask(this)
{
FCStringAnsi::Strncpy(HostName,InHostName,256);
}
/**
* Resolves the specified host name
*/
void FResolveInfoAsync::DoWork()
{
int32 AttemptCount = 0;
ISocketSubsystem* SocketSubsystem = ISocketSubsystem::Get();
// Make up to 3 attempts to resolve it
do
{
FAddressInfoResult GAIResults = SocketSubsystem->GetAddressInfo(ANSI_TO_TCHAR(HostName), nullptr, EAddressInfoFlags::Default, NAME_None);
ErrorCode = GAIResults.ReturnCode;
if (ErrorCode != SE_NO_ERROR)
{
if (ErrorCode == SE_HOST_NOT_FOUND || ErrorCode == SE_NO_DATA || ErrorCode == SE_ETIMEDOUT)
{
// Force a failure
AttemptCount = 3;
}
}
else if(GAIResults.Results.Num() > 0)
{
// Pull out the address
Addr = GAIResults.Results[0].Address;
// Cache for reuse
SocketSubsystem->AddHostNameToCache(HostName, Addr);
return;
}
else
{
ErrorCode = SE_NO_DATA;
}
AttemptCount++;
}
while (ErrorCode != SE_NO_ERROR && AttemptCount < 3 && bShouldAbandon == false);
}