mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-11-08 14:28:21 +01:00
Only use EAI_OVERFLOW, AI_NUMERICSERV if defined
Some systems like Mac OS X 10.5 (and lower) do not have EAI_OVERFLOW and AI_NUMERICSERV defined. These variables are used to avoid a potentially slow name resolution for the hostname (which will always be an ip address) and for service name (which will always be an actual port number). The code might be slower, but it should still work. Closes: #242
This commit is contained in:
parent
c0fba03e4f
commit
d9afe3fd9c
@ -188,7 +188,10 @@ static int meth_sendto(lua_State *L) {
|
||||
memset(&aihint, 0, sizeof(aihint));
|
||||
aihint.ai_family = udp->family;
|
||||
aihint.ai_socktype = SOCK_DGRAM;
|
||||
aihint.ai_flags = AI_NUMERICHOST | AI_NUMERICSERV;
|
||||
aihint.ai_flags = AI_NUMERICHOST;
|
||||
#ifdef AI_NUMERICSERV
|
||||
aihint.ai_flags |= AI_NUMERICSERV;
|
||||
#endif
|
||||
err = getaddrinfo(ip, port, &aihint, &ai);
|
||||
if (err) {
|
||||
lua_pushnil(L);
|
||||
|
@ -440,7 +440,9 @@ LUASOCKET_PRIVATE const char *socket_gaistrerror(int err) {
|
||||
case EAI_FAMILY: return PIE_FAMILY;
|
||||
case EAI_MEMORY: return PIE_MEMORY;
|
||||
case EAI_NONAME: return PIE_NONAME;
|
||||
#ifdef EAI_OVERFLOW
|
||||
case EAI_OVERFLOW: return PIE_OVERFLOW;
|
||||
#endif
|
||||
#ifdef EAI_PROTOCOL
|
||||
case EAI_PROTOCOL: return PIE_PROTOCOL;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user