I tried 16_Chat on my iPad and got an exception .
This is a general issue for both iOS and macOS , getaddrinfo() returns NULL if passing the hostname.
But on my Mac I fixed it by adding my hostname to /etc/hosts
Anyway I fixed it by modifying the function below , the code is compiled to support IPv4 only.
If you will compile the code to support IPv6 (RAKNET_SUPPORT_IPV6==1) you will also have to modify the function GetMyIP_Windows_Linux_IPV4And6().
With the below fix you won’t need to modify /etc/hosts on macOS.
Basically so far I verified it on 3 devices connected to my WIFI LAN .
Windows laptop
Mac laptop
iPad
The chat app runs on all 3 , with the 2 fixes , all 3 can send/receive messages to/from each other.
void GetMyIP_Windows_Linux_IPV4( SystemAddress addresses[MAXIMUM_NUMBER_OF_INTERNAL_IDS] )
{
int idx=0;
char ac[ 80 ];
int err = gethostname( ac, sizeof( ac ) );
(void) err;
RakAssert(err != -1);
const char *localhost_str="localhost";
struct addrinfo *curAddress = NULL;
err = getaddrinfo(ac, NULL, NULL, &curAddress);
if(curAddress == NULL)
{
err = getaddrinfo(localhost_str, NULL, NULL, &curAddress);
}
if ( err != 0 || curAddress == 0 )
{
RakAssert(false);
return ;
}
while (curAddress != NULL && idx < MAXIMUM_NUMBER_OF_INTERNAL_IDS)
{
if (curAddress->ai_family == AF_INET) {
addresses[idx].address.addr4 = *((struct sockaddr_in *)curAddress->ai_addr);
++idx;
}
curAddress = curAddress->ai_next;
}
while (idx < MAXIMUM_NUMBER_OF_INTERNAL_IDS)
{
addresses[idx]=UNASSIGNED_SYSTEM_ADDRESS;
idx++;
}
}