aboutsummaryrefslogtreecommitdiff
path: root/src/inet.c
diff options
context:
space:
mode:
authorDiego Nehab <diego@impa.br>2012-12-11 16:35:27 -0200
committerDiego Nehab <diego@impa.br>2012-12-11 16:35:27 -0200
commit618ce43ee3950b80aca1fde0a5b12e6e13627f1b (patch)
treefc97079e13e071593086a3d6aa5b090b96c744a3 /src/inet.c
parent66670c354146feb8c9603f10682fabcba44a05a9 (diff)
downloadluasocket-618ce43ee3950b80aca1fde0a5b12e6e13627f1b.tar.gz
luasocket-618ce43ee3950b80aca1fde0a5b12e6e13627f1b.tar.bz2
luasocket-618ce43ee3950b80aca1fde0a5b12e6e13627f1b.zip
Fix socket_accept usage to depend on family.
Diffstat (limited to 'src/inet.c')
-rw-r--r--src/inet.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/inet.c b/src/inet.c
index dfee700..52f7397 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -263,7 +263,6 @@ int inet_meth_getpeername(lua_State *L, p_socket ps, int family)
263 lua_pushliteral(L, "inet6"); 263 lua_pushliteral(L, "inet6");
264 return 3; 264 return 3;
265 } 265 }
266 return 2;
267 } 266 }
268 default: 267 default:
269 lua_pushnil(L); 268 lua_pushnil(L);
@@ -424,6 +423,21 @@ const char *inet_tryconnect(p_socket ps, const char *address,
424} 423}
425 424
426/*-------------------------------------------------------------------------*\ 425/*-------------------------------------------------------------------------*\
426* Tries to accept a socket
427\*-------------------------------------------------------------------------*/
428const char *inet_tryaccept(p_socket server, int family, p_socket client, p_timeout tm)
429{
430 socklen_t len;
431 t_sockaddr_storage addr;
432 if (family == PF_INET6) {
433 len = sizeof(struct sockaddr_in6);
434 } else {
435 len = sizeof(struct sockaddr_in);
436 }
437 return socket_strerror(socket_accept(server, client, (SA *) &addr, &len, tm));
438}
439
440/*-------------------------------------------------------------------------*\
427* Tries to bind socket to (address, port) 441* Tries to bind socket to (address, port)
428\*-------------------------------------------------------------------------*/ 442\*-------------------------------------------------------------------------*/
429const char *inet_trybind(p_socket ps, const char *address, const char *serv, 443const char *inet_trybind(p_socket ps, const char *address, const char *serv,