UDP C++ works on Windows but not on Android

Hi all!

My problem is very simple, I need to send custom data from one project to another using UDP, I modified the famous Rama tutorial;

The following code works perfectly on Windows (using “192.168.1.2” as the IP address where I will send the data) but return false on Android (at least on my Moto Z Play running Android 6.0.1).

It’s the EXACT same project, the first time running on Windows, the second time running on Android.

Is there a specific reason why RemoteAddr->SetIp should return false with “192.168.1.2”?
Are there some obscure Android limitations about UDP?

(I had problems with UDP using Data then I found out it’s blocked by some ISPs, but I’m doing this on Wifi)

bool UUDPSender::StartUDPSender(const FString& TheIP)
{
	//Create Remote Address.
	RemoteAddr = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr();

	bool bIsValid;
	RemoteAddr->SetIp(*TheIP, bIsValid);
	RemoteAddr->SetPort(8990);

	if (!bIsValid)
	{
		return false;
	}

	SenderSocket = FUdpSocketBuilder("RemoteAndroidSenderSocket").AsReusable().WithBroadcast();

	int32 SendSize = 2 * 1024 * 1024;
	SenderSocket->SetSendBufferSize(SendSize, SendSize);
	SenderSocket->SetReceiveBufferSize(SendSize, SendSize);

	return true;
}

I will reply to myself to help someone else with the same problem.

After hours of investigation I’ve found the problem causing it:
all of this is caused because I made this code as a custom Plugin.

I tried making a simple Dummy function like this:

FVector UUDPSender::dummy()
{
	return FVector(1, 2, 3);
}

It returns (1,2,3) on Windows but (0,0,0) on Android, so I understood the problem wasn’t the FSocket library, but the fact that the C++ function wasn’t even called! (and the default bool value and default FVector values were used)

I actually don’t know why the plugin isn’t being loaded on Android, but I’ve found a similar problem in the AnswerHub:
Custom Plugins in Android don’t work.

So to “fix” it I decided to convert my code into a Module instead of a Plugin and this time it was loaded and the UDP and the Dummy functions worked perfectly