summaryrefslogtreecommitdiff
path: root/src/l_tcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/l_tcp.c')
-rw-r--r--src/l_tcp.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/l_tcp.c b/src/l_tcp.c
index d96742c..d06a251 100644
--- a/src/l_tcp.c
+++ b/src/l_tcp.c
@@ -400,7 +400,7 @@ static int l_tcp_endtostring(lua_State *L)
return 1;
}
-static const struct luaL_reg tcp_funcs [] = {
+static const struct luaL_Reg tcp_funcs [] = {
{ "server", l_tcp_server },
{ "accept", l_tcp_accept },
{ "client", l_tcp_client },
@@ -413,6 +413,13 @@ static const struct luaL_reg tcp_funcs [] = {
LUALIB_API int luaopen_tcp(lua_State *L)
{
+#if LUA_VERSION_NUM > 501
+ lua_newtable(L);
+ luaL_setfuncs(L, tcp_funcs, 0);
+ lua_pushvalue(L, -1);
+ lua_setglobal(L, LUA_TCPLIBNAME);
+#else
luaL_register(L, LUA_TCPLIBNAME, tcp_funcs);
+#endif
return 1;
}