Hey everyone,
When connected to localhost, GetAddrAsInt works well:
but when connected to a internet IP, it returns a negative integer:
Below is the code i used to get both screen captures (in the player controller’s BeginPlayingState()).
if (!IsLocalPlayerController() || Role == ROLE_Authority) return false;
int32 IntIP = ()->NetDriver->ServerConnection->GetAddrAsInt();
FString IntIPStr = FString::FromInt(IntIP);
int32 ServerIPa = IntIP / (256 * 256 * 256);
int32 ServerIPb = (IntIP - ServerIPa * 256 * 256 * 256) / (256 * 256);
int32 ServerIPc = (IntIP - ServerIPa * 256 * 256 * 256 - ServerIPb * 256 * 256) / 256;
int32 ServerIPd = (IntIP - ServerIPa * 256 * 256 * 256 - ServerIPb * 256 * 256 - ServerIPc * 256);
FString ServerIP = FString::FromInt(ServerIPa) + "." + FString::FromInt(ServerIPb) + "." + FString::FromInt(ServerIPc) + "." + FString::FromInt(ServerIPd);
GEngine->AddOnScreenDebugMessage(-1, 50.f, FColor::Yellow, TEXT("IP int: " + IntIPStr + " = " + ServerIP));
Cedric