add portable enet_address_set_host_ip that can properly parse broadcast address

This commit is contained in:
Lee Salzman
2017-05-06 14:55:03 -04:00
parent f46fee0acc
commit 3ae5af4548
3 changed files with 52 additions and 15 deletions
+14 -8
View File
@@ -101,6 +101,19 @@ enet_time_set (enet_uint32 newTimeBase)
timeBase = timeVal.tv_sec * 1000 + timeVal.tv_usec / 1000 - newTimeBase;
}
int
enet_address_set_host_ip (ENetAddress * address, const char * name)
{
#ifdef HAS_INET_PTON
if (! inet_pton (AF_INET, name, & address -> host))
#else
if (! inet_aton (name, (struct in_addr *) & address -> host))
#endif
return -1;
return 0;
}
int
enet_address_set_host (ENetAddress * address, const char * name)
{
@@ -153,14 +166,7 @@ enet_address_set_host (ENetAddress * address, const char * name)
}
#endif
#ifdef HAS_INET_PTON
if (! inet_pton (AF_INET, name, & address -> host))
#else
if (! inet_aton (name, (struct in_addr *) & address -> host))
#endif
return -1;
return 0;
return enet_address_set_host_ip (address, name);
}
int