diff options
Diffstat (limited to 'src/udp.c')
-rw-r--r-- | src/udp.c | 32 |
1 files changed, 2 insertions, 30 deletions
@@ -30,7 +30,6 @@ static int meth_getpeername(lua_State *L); | |||
30 | static int meth_setsockname(lua_State *L); | 30 | static int meth_setsockname(lua_State *L); |
31 | static int meth_setpeername(lua_State *L); | 31 | static int meth_setpeername(lua_State *L); |
32 | static int meth_close(lua_State *L); | 32 | static int meth_close(lua_State *L); |
33 | static int meth_shutdown(lua_State *L); | ||
34 | static int meth_setoption(lua_State *L); | 33 | static int meth_setoption(lua_State *L); |
35 | static int meth_settimeout(lua_State *L); | 34 | static int meth_settimeout(lua_State *L); |
36 | static int meth_getfd(lua_State *L); | 35 | static int meth_getfd(lua_State *L); |
@@ -49,7 +48,6 @@ static luaL_reg udp[] = { | |||
49 | {"receivefrom", meth_receivefrom}, | 48 | {"receivefrom", meth_receivefrom}, |
50 | {"settimeout", meth_settimeout}, | 49 | {"settimeout", meth_settimeout}, |
51 | {"close", meth_close}, | 50 | {"close", meth_close}, |
52 | {"shutdown", meth_shutdown}, | ||
53 | {"setoption", meth_setoption}, | 51 | {"setoption", meth_setoption}, |
54 | {"__gc", meth_close}, | 52 | {"__gc", meth_close}, |
55 | {"getfd", meth_getfd}, | 53 | {"getfd", meth_getfd}, |
@@ -79,7 +77,7 @@ static luaL_reg func[] = { | |||
79 | /*-------------------------------------------------------------------------*\ | 77 | /*-------------------------------------------------------------------------*\ |
80 | * Initializes module | 78 | * Initializes module |
81 | \*-------------------------------------------------------------------------*/ | 79 | \*-------------------------------------------------------------------------*/ |
82 | void udp_open(lua_State *L) | 80 | int udp_open(lua_State *L) |
83 | { | 81 | { |
84 | /* create classes */ | 82 | /* create classes */ |
85 | aux_newclass(L, "udp{connected}", udp); | 83 | aux_newclass(L, "udp{connected}", udp); |
@@ -92,6 +90,7 @@ void udp_open(lua_State *L) | |||
92 | /* define library functions */ | 90 | /* define library functions */ |
93 | luaL_openlib(L, LUASOCKET_LIBNAME, func, 0); | 91 | luaL_openlib(L, LUASOCKET_LIBNAME, func, 0); |
94 | lua_pop(L, 1); | 92 | lua_pop(L, 1); |
93 | return 0; | ||
95 | } | 94 | } |
96 | 95 | ||
97 | /*=========================================================================*\ | 96 | /*=========================================================================*\ |
@@ -288,33 +287,6 @@ static int meth_close(lua_State *L) | |||
288 | } | 287 | } |
289 | 288 | ||
290 | /*-------------------------------------------------------------------------*\ | 289 | /*-------------------------------------------------------------------------*\ |
291 | * Shuts the connection down partially | ||
292 | \*-------------------------------------------------------------------------*/ | ||
293 | static int meth_shutdown(lua_State *L) | ||
294 | { | ||
295 | p_udp udp = (p_udp) aux_checkgroup(L, "udp{any}", 1); | ||
296 | const char *how = luaL_optstring(L, 2, "both"); | ||
297 | switch (how[0]) { | ||
298 | case 'b': | ||
299 | if (strcmp(how, "both")) goto error; | ||
300 | sock_shutdown(&udp->sock, 2); | ||
301 | break; | ||
302 | case 's': | ||
303 | if (strcmp(how, "send")) goto error; | ||
304 | sock_shutdown(&udp->sock, 1); | ||
305 | break; | ||
306 | case 'r': | ||
307 | if (strcmp(how, "receive")) goto error; | ||
308 | sock_shutdown(&udp->sock, 0); | ||
309 | break; | ||
310 | } | ||
311 | return 0; | ||
312 | error: | ||
313 | luaL_argerror(L, 2, "invalid shutdown method"); | ||
314 | return 0; | ||
315 | } | ||
316 | |||
317 | /*-------------------------------------------------------------------------*\ | ||
318 | * Turns a master object into a server object | 290 | * Turns a master object into a server object |
319 | \*-------------------------------------------------------------------------*/ | 291 | \*-------------------------------------------------------------------------*/ |
320 | static int meth_setsockname(lua_State *L) | 292 | static int meth_setsockname(lua_State *L) |