# UDP C++ works on Windows but not on Android

**URL:** <https://forums.unrealengine.com/t/udp-c-works-on-windows-but-not-on-android/383439>\
**Category:** Multiplayer & Networking\
**Tags:** udp, Networking, fsocket, unreal-engine, Android, CPP, question\
**Created:** [January 30, 2017, 7:53pm UTC](https://forums.unrealengine.com/t/udp-c-works-on-windows-but-not-on-android/383439 "2017-01-30T19:53:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yatima1460](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Yatima1460](https://forums.unrealengine.com/u/Yatima1460)\
**Post date:** [January 30, 2017, 7:53pm UTC](https://forums.unrealengine.com/t/udp-c-works-on-windows-but-not-on-android/383439/1 "2017-01-30T19:53:42Z")

</div>

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](https://wiki.unrealengine.com/UDP_Socket_Sender_Receiver_From_One_UE4_Instance_To_Another);

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;
}

```

---

<div class="post-metadata">

**Author:** ![Yatima1460](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Yatima1460](https://forums.unrealengine.com/u/Yatima1460)\
**Post date:** [January 31, 2017, 3:34am UTC](https://forums.unrealengine.com/t/udp-c-works-on-windows-but-not-on-android/383439/2 "2017-01-31T03:34:39Z")

</div>

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.](https://answers.unrealengine.com/questions/59951/custom-plugins-in-android-dont-work.html)

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
