UDP Communication in iOS

Hello , I got a problem when I open my App in iPad. It uses the UDP Communication in GitHub , and it works well in two windows computers’ communications. But when I package to iOS ,and open in iPad, it breaks down right now after I open it.
When I disable the following codes , my App will not break down in iPad. But communication function is disable too.

I found that the UdpMessaging plugin used the same method.

What should we do to solve this problem…Great appreciation!

Maybe it just failed to build a udp socket.

确实是这样的。UpdSocket在Ipad上没有创建成功。但是在PC上测试是可以的。TT

SenderSocket = FUdpSocketBuilder(*SocketName) .AsReusable() .WithBroadcast();

UdpSocketBuilder created failed in iPad. So SenderSocket is NULL.
What should I do to make it create successful in iPad…Great appreciation~

I would like suggest you to take a look of ISocketSubsystem::GetLastErrorCode() first.

Normally you may got error like EACCES, which means your app socket permission denied. Then you may have to check root access or there is another app using same address.

没有创建成功的可能性很多,权限问题,端口被占用等等。
Socket属于底层功能,PC上能过 并不意味着手机平台上能过,甚至不同的IOS版本都会给你不同的结果。所以这才是开始。。。。

心好痛。。。蟹蟹。。。

I have found the reason , and use a method to avoid this problem(it is not a good solution , and I will keep going on UDP and TCP communication problem).

What I do is to rewrite the UdpSocketBuilder.h and disable the following code :
Error = !Socket->SetMulticastLoopback(MulticastLoopback) || !Socket->SetMulticastTtl(MulticastTtl);

It seems that “Multicast” will lead to some problem in iOS, and I am not able to solve it now .So I have to avoid it.

And I rewrite the following codes:

if (Socket!=NULL)
		{
			int32 OutNewSize;

			if (ReceiveBufferSize > 0)
			{
				Socket->SetReceiveBufferSize(ReceiveBufferSize, OutNewSize);
			}

			if (SendBufferSize > 0)
			{
				Socket->SetSendBufferSize(SendBufferSize, OutNewSize);
			}
		}

the above is all in MyUdpSocketBuilder.h which I copy from UdpSocketBuilder.h.

And I delete the function " WithBroadcast()" in UDPSender.cpp:

SenderSocket = FMyUdpSocketBuilder(*SocketName)
		.AsReusable();

All the above is according to the Plugin “udp-ue4-plugin-win64” made by AlekseiTepljakov , which is also according to RAMA’s working.

My version is 4.20

I will keep learning to solve the left problems.
Thanks to henryLiu~~~
谢啦老哥~~~