Unreal Cpp 获取本机IP地址

FString UCT3FunctionLibrary::GetLocalIPAddress()
{
    FString IpAddr("NONE");
    bool bCanBind = false;
    TSharedRef<FInternetAddr> localIp = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->GetLocalHostAddr(*GLog, bCanBind);
    if (localIp->IsValid())
    {
        IpAddr = localIp->ToString(false);
    }
    return IpAddr;
}

 

posted @ 2024-03-14 10:28  阿华小青蛙  阅读(25)  评论(0编辑  收藏  举报