diff --git a/Plugins/PerceptionNeuron/Source/PerceptionNeuron/Private/PerceptionNeuronController.cpp b/Plugins/PerceptionNeuron/Source/PerceptionNeuron/Private/PerceptionNeuronController.cpp index 6395401..60677a9 100644 --- a/Plugins/PerceptionNeuron/Source/PerceptionNeuron/Private/PerceptionNeuronController.cpp +++ b/Plugins/PerceptionNeuron/Source/PerceptionNeuron/Private/PerceptionNeuronController.cpp @@ -257,19 +257,34 @@ bool APerceptionNeuronController::Connect(FString HostName, int32 Port) if (ReceiverSocket == NULL) return false; - auto ResolveInfo = SocketSubSystem->GetHostByName(TCHAR_TO_ANSI(*HostName)); - while (!ResolveInfo->IsComplete()); + // Is HostName already a valid IPv4 address? + bool bValidAddress = false; + uint32 IP = 0; + FIPv4Address IPv4Address; + if (true == FIPv4Address::Parse(HostName, IPv4Address)) + { + IP = IPv4Address.Value; + bValidAddress = true; + } + else + { // Resolve HostName + auto ResolveInfo = SocketSubSystem->GetHostByName(TCHAR_TO_ANSI(*HostName)); + while (!ResolveInfo->IsComplete()); + + if (ResolveInfo->GetErrorCode() == 0) + { + const FInternetAddr* Addr = &ResolveInfo->GetResolvedAddress(); + Addr->GetIp(IP); + bValidAddress = true; + } + } - if (ResolveInfo->GetErrorCode() == 0) + // Connect + if (bValidAddress) { - const FInternetAddr* Addr = &ResolveInfo->GetResolvedAddress(); - uint32 IP; - Addr->GetIp(IP); - TSharedRef InetAddr = SocketSubSystem->CreateInternetAddr(); InetAddr->SetIp(IP); InetAddr->SetPort(Port); - bConnected = ReceiverSocket->Connect(*InetAddr); } }