Download

SocketSubsystem::GetAddressInfo not work

i’m using Socket connect. i found that it only support ip connect rather than url.
so i have to convert url to ip address. but when i using ‘GetAddressInfo’ get ip address could not connect.
i’m open windows cmd tool and input ‘ping myServerUrl’ get ip ,it’s different from ‘GetAddressInfo’ in ue4. some one help me please.
The code is:
FString rawIp = IP;
FAddressInfoResult GAIResult = SocketSubsystem->GetAddressInfo(*IP, nullptr, EAddressInfoFlags::Default, NAME_None, ESocketType::SOCKTYPE_Unknown);

if (GAIResult.Results.Num() > 0)
{
	TArrayView<uint8> ipArray = GAIResult.Results[0].Address->GetRawIp();
	rawIp = FString::Printf(TEXT("%d.%d.%d.%d"), ipArray[0], ipArray[1], ipArray[2], ipArray[3]);
	UE_LOG(LogTemp, Log, TEXT("this is ip:%s"), *rawIp);
}

i found problem. change to this is worked :
FString rawIp = IP;
FAddressInfoResult GAIResult = SocketSubsystem->GetAddressInfo(*IP, nullptr, EAddressInfoFlags::Default, NAME_None);

if (GAIResult.Results.Num() > 0)
{
	rawIp = GAIResult.Results[0].Address->ToString(false);
}