aboutsummaryrefslogtreecommitdiff
path: root/src/tcp.c
diff options
context:
space:
mode:
authorSam Roberts <vieuxtech@gmail.com>2012-02-27 13:26:23 -0800
committerSam Roberts <vieuxtech@gmail.com>2012-04-11 13:54:01 -0700
commit8bb542baaf30874479b83d37af2fea5fa84d0a8e (patch)
tree117d706140ee622565fa1c671c5469cb7f30fdac /src/tcp.c
parent0716cb868e847bb9f66c659f8662d905ba012de8 (diff)
downloadluasocket-8bb542baaf30874479b83d37af2fea5fa84d0a8e.tar.gz
luasocket-8bb542baaf30874479b83d37af2fea5fa84d0a8e.tar.bz2
luasocket-8bb542baaf30874479b83d37af2fea5fa84d0a8e.zip
Support getoption method for tcp objects.
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 539ad5e..4713b23 100644
--- a/src/tcp.c
+++ b/src/tcp.c
@@ -31,6 +31,7 @@ static int meth_shutdown(lua_State *L);
31static int meth_receive(lua_State *L); 31static int meth_receive(lua_State *L);
32static int meth_accept(lua_State *L); 32static int meth_accept(lua_State *L);
33static int meth_close(lua_State *L); 33static int meth_close(lua_State *L);
34static int meth_getoption(lua_State *L);
34static int meth_setoption(lua_State *L); 35static int meth_setoption(lua_State *L);
35static int meth_settimeout(lua_State *L); 36static int meth_settimeout(lua_State *L);
36static int meth_getfd(lua_State *L); 37static int meth_getfd(lua_State *L);
@@ -47,6 +48,7 @@ static luaL_reg tcp[] = {
47 {"connect", meth_connect}, 48 {"connect", meth_connect},
48 {"dirty", meth_dirty}, 49 {"dirty", meth_dirty},
49 {"getfd", meth_getfd}, 50 {"getfd", meth_getfd},
51 {"getoption", meth_getoption},
50 {"getpeername", meth_getpeername}, 52 {"getpeername", meth_getpeername},
51 {"getsockname", meth_getsockname}, 53 {"getsockname", meth_getsockname},
52 {"getstats", meth_getstats}, 54 {"getstats", meth_getstats},
@@ -64,6 +66,14 @@ static luaL_reg tcp[] = {
64}; 66};
65 67
66/* socket option handlers */ 68/* socket option handlers */
69static t_opt optget[] = {
70 {"keepalive", opt_get_keepalive},
71 {"reuseaddr", opt_get_reuseaddr},
72 {"tcp-nodelay", opt_get_tcp_nodelay},
73 {"linger", opt_get_linger},
74 {NULL, NULL}
75};
76
67static t_opt opt[] = { 77static t_opt opt[] = {
68 {"keepalive", opt_keepalive}, 78 {"keepalive", opt_keepalive},
69 {"reuseaddr", opt_reuseaddr}, 79 {"reuseaddr", opt_reuseaddr},
@@ -125,6 +135,12 @@ static int meth_setstats(lua_State *L) {
125/*-------------------------------------------------------------------------*\ 135/*-------------------------------------------------------------------------*\
126* Just call option handler 136* Just call option handler
127\*-------------------------------------------------------------------------*/ 137\*-------------------------------------------------------------------------*/
138static int meth_getoption(lua_State *L)
139{
140 p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1);
141 return opt_meth_getoption(L, optget, &tcp->sock);
142}
143
128static int meth_setoption(lua_State *L) 144static int meth_setoption(lua_State *L)
129{ 145{
130 p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1); 146 p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1);