aboutsummaryrefslogtreecommitdiff
path: root/src/lua/net/luaopen_net.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-05-17 19:10:57 +0800
committerchai <chaifix@163.com>2018-05-17 19:10:57 +0800
commit70cdd89e887641b7423e5d4d05928d14ee014aba (patch)
tree248b87ae35197a9e5941e65ef20eea359e87a5ed /src/lua/net/luaopen_net.cpp
parentdf4b054b8e8d00f7817daaa4cbf6961712cd0b75 (diff)
change file tree
Diffstat (limited to 'src/lua/net/luaopen_net.cpp')
-rw-r--r--src/lua/net/luaopen_net.cpp110
1 files changed, 0 insertions, 110 deletions
diff --git a/src/lua/net/luaopen_net.cpp b/src/lua/net/luaopen_net.cpp
deleted file mode 100644
index 4cb7cea..0000000
--- a/src/lua/net/luaopen_net.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
-* Notice: the net module is not finished yet.
-*/
-#include "libs/luax/luax.h"
-#include "libs/tekcos/tekcos.h"
-
-namespace jin
-{
-namespace lua
-{
- struct
- {
- tk_TCPsocket* sk;
- }context;
-
- /**
- * A table is needed. For example:
- * local conf = {
- * mode = "server",
- * ip = "",
- * port = 8000
- * }
- */
- static int l_open(lua_State* L)
- {
- // init context.sk
- context.sk = 0;
- if (!luax_istable(L, 1))
- {
- luax_typerror(L, 1, "table is needed");
- return 0;
- }
- luax_getfield(L, 1, "mode");
- if (luax_isnil(L, -1))
- {// no mode field
- luax_error(L, "mode field is needed, but get nil");
- return 0;
- }
- const char* mode = luax_checkstring(L, -1);
- if (strcmp(mode, "server") == 0 || strcmp(mode, "client") == 0)
- {
-
- if (strcmp(mode, "server") == 0)
- {// a server, ignore ip field
-
- }
- else
- {
-
- }
- }
- else
- {
- luax_error(L, "\"server\" or \"client\" is needed, but get %s", mode);
- return 0;
- }
- return 1;
- }
-
- static int l_accept(lua_State* L)
- {
- return 1;
- }
-
- static int l_send(lua_State* L)
- {
- return 1;
- }
-
- static int l_recv(lua_State* L)
- {
- return 1;
- }
-
- static int l_close(lua_State* L)
- {
- return 1;
- }
-
- static int l_nonblocking(lua_State* L)
- {
- return 1;
- }
-
- // block mode by default
- static int l_blocking(lua_State* L)
- {
- return 1;
- }
-
- static const luaL_Reg f[] = {
- {"open", l_open},
- {"accept", l_accept},
- {"send", l_send},
- {"recv", l_recv},
- {"close", l_close},
- {"blocking", l_blocking },
- {"nonblocking", l_nonblocking},
- {0, 0}
- };
-
- // only tcp
- int luaopen_net(lua_State* L)
- {
- luax_newlib(L, f);
-
- return 1;
- }
-}
-} \ No newline at end of file