aboutsummaryrefslogtreecommitdiff
path: root/src/inet.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-x[-rw-r--r--]src/inet.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/inet.c b/src/inet.c
index 331b800..138c9ab 100644..100755
--- a/src/inet.c
+++ b/src/inet.c
@@ -2,16 +2,13 @@
2* Internet domain functions 2* Internet domain functions
3* LuaSocket toolkit 3* LuaSocket toolkit
4\*=========================================================================*/ 4\*=========================================================================*/
5#include "luasocket.h"
6#include "inet.h"
7
5#include <stdio.h> 8#include <stdio.h>
6#include <stdlib.h> 9#include <stdlib.h>
7#include <string.h> 10#include <string.h>
8 11
9#include "lua.h"
10#include "lauxlib.h"
11#include "compat.h"
12
13#include "inet.h"
14
15/*=========================================================================*\ 12/*=========================================================================*\
16* Internal function prototypes. 13* Internal function prototypes.
17\*=========================================================================*/ 14\*=========================================================================*/
@@ -32,9 +29,6 @@ static luaL_Reg func[] = {
32 { NULL, NULL} 29 { NULL, NULL}
33}; 30};
34 31
35/*=========================================================================*\
36* Exported functions
37\*=========================================================================*/
38/*-------------------------------------------------------------------------*\ 32/*-------------------------------------------------------------------------*\
39* Initializes module 33* Initializes module
40\*-------------------------------------------------------------------------*/ 34\*-------------------------------------------------------------------------*/
@@ -259,7 +253,7 @@ int inet_meth_getpeername(lua_State *L, p_socket ps, int family)
259 port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV); 253 port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV);
260 if (err) { 254 if (err) {
261 lua_pushnil(L); 255 lua_pushnil(L);
262 lua_pushstring(L, gai_strerror(err)); 256 lua_pushstring(L, LUA_GAI_STRERROR(err));
263 return 2; 257 return 2;
264 } 258 }
265 lua_pushstring(L, name); 259 lua_pushstring(L, name);
@@ -292,7 +286,7 @@ int inet_meth_getsockname(lua_State *L, p_socket ps, int family)
292 name, INET6_ADDRSTRLEN, port, 6, NI_NUMERICHOST | NI_NUMERICSERV); 286 name, INET6_ADDRSTRLEN, port, 6, NI_NUMERICHOST | NI_NUMERICSERV);
293 if (err) { 287 if (err) {
294 lua_pushnil(L); 288 lua_pushnil(L);
295 lua_pushstring(L, gai_strerror(err)); 289 lua_pushstring(L, LUA_GAI_STRERROR(err));
296 return 2; 290 return 2;
297 } 291 }
298 lua_pushstring(L, name); 292 lua_pushstring(L, name);
@@ -423,8 +417,8 @@ const char *inet_tryconnect(p_socket ps, int *family, const char *address,
423 /* try connecting to remote address */ 417 /* try connecting to remote address */
424 err = socket_strerror(socket_connect(ps, (SA *) iterator->ai_addr, 418 err = socket_strerror(socket_connect(ps, (SA *) iterator->ai_addr,
425 (socklen_t) iterator->ai_addrlen, tm)); 419 (socklen_t) iterator->ai_addrlen, tm));
426 /* if success, break out of loop */ 420 /* if success or timeout is zero, break out of loop */
427 if (err == NULL) { 421 if (err == NULL || timeout_iszero(tm)) {
428 *family = current_family; 422 *family = current_family;
429 break; 423 break;
430 } 424 }