diff options
| author | Sam Roberts <vieuxtech@gmail.com> | 2012-02-27 13:26:23 -0800 |
|---|---|---|
| committer | Sam Roberts <vieuxtech@gmail.com> | 2012-04-11 13:54:01 -0700 |
| commit | 8bb542baaf30874479b83d37af2fea5fa84d0a8e (patch) | |
| tree | 117d706140ee622565fa1c671c5469cb7f30fdac /src/tcp.c | |
| parent | 0716cb868e847bb9f66c659f8662d905ba012de8 (diff) | |
| download | luasocket-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.c | 16 |
1 files changed, 16 insertions, 0 deletions
| @@ -31,6 +31,7 @@ static int meth_shutdown(lua_State *L); | |||
| 31 | static int meth_receive(lua_State *L); | 31 | static int meth_receive(lua_State *L); |
| 32 | static int meth_accept(lua_State *L); | 32 | static int meth_accept(lua_State *L); |
| 33 | static int meth_close(lua_State *L); | 33 | static int meth_close(lua_State *L); |
| 34 | static int meth_getoption(lua_State *L); | ||
| 34 | static int meth_setoption(lua_State *L); | 35 | static int meth_setoption(lua_State *L); |
| 35 | static int meth_settimeout(lua_State *L); | 36 | static int meth_settimeout(lua_State *L); |
| 36 | static int meth_getfd(lua_State *L); | 37 | static 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 */ |
| 69 | static 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 | |||
| 67 | static t_opt opt[] = { | 77 | static 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 | \*-------------------------------------------------------------------------*/ |
| 138 | static 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 | |||
| 128 | static int meth_setoption(lua_State *L) | 144 | static 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); |
