aboutsummaryrefslogtreecommitdiff
path: root/src/tcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tcp.c')
-rw-r--r--src/tcp.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/tcp.c b/src/tcp.c
index 19ee73c..3146467 100644
--- a/src/tcp.c
+++ b/src/tcp.c
@@ -33,6 +33,7 @@ static int meth_shutdown(lua_State *L);
33static int meth_receive(lua_State *L); 33static int meth_receive(lua_State *L);
34static int meth_accept(lua_State *L); 34static int meth_accept(lua_State *L);
35static int meth_close(lua_State *L); 35static int meth_close(lua_State *L);
36static int meth_getoption(lua_State *L);
36static int meth_setoption(lua_State *L); 37static int meth_setoption(lua_State *L);
37static int meth_settimeout(lua_State *L); 38static int meth_settimeout(lua_State *L);
38static int meth_getfd(lua_State *L); 39static int meth_getfd(lua_State *L);
@@ -49,6 +50,7 @@ static luaL_Reg tcp_methods[] = {
49 {"connect", meth_connect}, 50 {"connect", meth_connect},
50 {"dirty", meth_dirty}, 51 {"dirty", meth_dirty},
51 {"getfd", meth_getfd}, 52 {"getfd", meth_getfd},
53 {"getoption", meth_getoption},
52 {"getpeername", meth_getpeername}, 54 {"getpeername", meth_getpeername},
53 {"getsockname", meth_getsockname}, 55 {"getsockname", meth_getsockname},
54 {"getstats", meth_getstats}, 56 {"getstats", meth_getstats},
@@ -66,6 +68,14 @@ static luaL_Reg tcp_methods[] = {
66}; 68};
67 69
68/* socket option handlers */ 70/* socket option handlers */
71static t_opt optget[] = {
72 {"keepalive", opt_get_keepalive},
73 {"reuseaddr", opt_get_reuseaddr},
74 {"tcp-nodelay", opt_get_tcp_nodelay},
75 {"linger", opt_get_linger},
76 {NULL, NULL}
77};
78
69static t_opt optset[] = { 79static t_opt optset[] = {
70 {"keepalive", opt_set_keepalive}, 80 {"keepalive", opt_set_keepalive},
71 {"reuseaddr", opt_set_reuseaddr}, 81 {"reuseaddr", opt_set_reuseaddr},
@@ -130,6 +140,12 @@ static int meth_setstats(lua_State *L) {
130/*-------------------------------------------------------------------------*\ 140/*-------------------------------------------------------------------------*\
131* Just call option handler 141* Just call option handler
132\*-------------------------------------------------------------------------*/ 142\*-------------------------------------------------------------------------*/
143static int meth_getoption(lua_State *L)
144{
145 p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1);
146 return opt_meth_getoption(L, optget, &tcp->sock);
147}
148
133static int meth_setoption(lua_State *L) 149static int meth_setoption(lua_State *L)
134{ 150{
135 p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1); 151 p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1);