I am attempting to communicate between Unreal and another process using the FSocket socket programming API provided by Unreal. Here is my code:
//Networking configuration
FIPv4Address ip(127, 0, 0, 1);
Socket = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateSocket(NAME_Stream, TEXT("default"), false);
TSharedRef<FInternetAddr> addr = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr();
addr->SetIp(ip.Value);
addr->SetPort(port);
if (Socket->Bind(*addr)) {
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Bind Successful!"));
}
else {
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Bind Not Successful!"));
}
The output generated is “Bind Not Successful!”, meaning that my call to Bind() is failing.
What could I be doing wrong here?
My intent is to listen on the loopback address. The selected port is 50323.