I am developing a UE4 game that requires to bind a socket(created from posix api) to cellular interface in c++(which is UE4 only capable of). But no matter what i tried, i always got 'deny(1) network-bind*:0'.
Here is how i bind that:
void FSocketSubsystemIOS::BindSocketToCellular(int fd)
{
ifaddrs* Interfaces = NULL;
if (getifaddrs(&Interfaces) != 0) return;
for (ifaddrs* Travel = Interfaces; Travel != NULL; Travel = Travel->ifa_next)
{
if (Travel->ifa_addr->sa_family == AF_INET)
{
if (strcmp(Travel->ifa_name, "pdp_ip0") == 0)
{
if (int err = bind(fd, Travel->ifa_addr, sizeof(*Travel->ifa_addr)))
{
CellularBondMap.Add(fd, false);
UE_LOG(LogIOS, Error, TEXT("[socket binding] cannot bind to pdp_ip0, errno: %d"), errno);
}
else
{
CellularBondMap.Add(fd, true);
UE_LOG(LogIOS, Error, TEXT("[socket binding] bind to pdp_ip0"));
}
}
}
}
freeifaddrs(Interfaces);
}
I have tried to add entitlements
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
but never worked.
However, I also tried this in a small iOS app that i build from scratch, and do this in c++, it works.
Can anybody helps me?