diff options
Diffstat (limited to 'src/tcp.c')
-rw-r--r-- | src/tcp.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -154,7 +154,7 @@ static int meth_connect(lua_State *L) | |||
154 | { | 154 | { |
155 | p_tcp tcp = (p_tcp) aux_checkclass(L, "tcp{master}", 1); | 155 | p_tcp tcp = (p_tcp) aux_checkclass(L, "tcp{master}", 1); |
156 | const char *address = luaL_checkstring(L, 2); | 156 | const char *address = luaL_checkstring(L, 2); |
157 | unsigned short port = (ushort) luaL_checknumber(L, 3); | 157 | unsigned short port = (unsigned short) luaL_checknumber(L, 3); |
158 | const char *err = inet_tryconnect(&tcp->sock, address, port); | 158 | const char *err = inet_tryconnect(&tcp->sock, address, port); |
159 | if (err) { | 159 | if (err) { |
160 | lua_pushnil(L); | 160 | lua_pushnil(L); |
@@ -174,7 +174,7 @@ static int meth_bind(lua_State *L) | |||
174 | { | 174 | { |
175 | p_tcp tcp = (p_tcp) aux_checkclass(L, "tcp{master}", 1); | 175 | p_tcp tcp = (p_tcp) aux_checkclass(L, "tcp{master}", 1); |
176 | const char *address = luaL_checkstring(L, 2); | 176 | const char *address = luaL_checkstring(L, 2); |
177 | unsigned short port = (ushort) luaL_checknumber(L, 3); | 177 | unsigned short port = (unsigned short) luaL_checknumber(L, 3); |
178 | int backlog = (int) luaL_optnumber(L, 4, 1); | 178 | int backlog = (int) luaL_optnumber(L, 4, 1); |
179 | const char *err = inet_trybind(&tcp->sock, address, port, backlog); | 179 | const char *err = inet_trybind(&tcp->sock, address, port, backlog); |
180 | if (err) { | 180 | if (err) { |
@@ -227,12 +227,13 @@ static int meth_accept(lua_State *L) | |||
227 | \*-------------------------------------------------------------------------*/ | 227 | \*-------------------------------------------------------------------------*/ |
228 | int global_create(lua_State *L) | 228 | int global_create(lua_State *L) |
229 | { | 229 | { |
230 | const char *err; | ||
230 | /* allocate tcp object */ | 231 | /* allocate tcp object */ |
231 | p_tcp tcp = (p_tcp) lua_newuserdata(L, sizeof(t_tcp)); | 232 | p_tcp tcp = (p_tcp) lua_newuserdata(L, sizeof(t_tcp)); |
232 | /* set its type as master object */ | 233 | /* set its type as master object */ |
233 | aux_setclass(L, "tcp{master}", -1); | 234 | aux_setclass(L, "tcp{master}", -1); |
234 | /* try to allocate a system socket */ | 235 | /* try to allocate a system socket */ |
235 | const char *err = inet_trycreate(&tcp->sock, SOCK_STREAM); | 236 | err = inet_trycreate(&tcp->sock, SOCK_STREAM); |
236 | if (err) { /* get rid of object on stack and push error */ | 237 | if (err) { /* get rid of object on stack and push error */ |
237 | lua_pop(L, 1); | 238 | lua_pop(L, 1); |
238 | lua_pushnil(L); | 239 | lua_pushnil(L); |