diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-06-21 06:07:58 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-06-21 06:07:58 +0000 |
| commit | bce1cb30d856d167e167c4c2997f9bebe03a612c (patch) | |
| tree | 8e684b912cdc9d27c5aebf593107487c94866438 /src/tcp.c | |
| parent | f7579db9e830ef41f422a280d26c9077f48728e5 (diff) | |
| download | luasocket-bce1cb30d856d167e167c4c2997f9bebe03a612c.tar.gz luasocket-bce1cb30d856d167e167c4c2997f9bebe03a612c.tar.bz2 luasocket-bce1cb30d856d167e167c4c2997f9bebe03a612c.zip | |
More adjustments/bugfixes.
Diffstat (limited to 'src/tcp.c')
| -rw-r--r-- | src/tcp.c | 6 |
1 files changed, 4 insertions, 2 deletions
| @@ -130,7 +130,7 @@ static int meth_setoption(lua_State *L) | |||
| 130 | static int meth_getfd(lua_State *L) | 130 | static int meth_getfd(lua_State *L) |
| 131 | { | 131 | { |
| 132 | p_tcp tcp = (p_tcp) aux_checkgroup(L, "tcp{any}", 1); | 132 | p_tcp tcp = (p_tcp) aux_checkgroup(L, "tcp{any}", 1); |
| 133 | lua_pushnumber(L, tcp->sock); | 133 | lua_pushnumber(L, (int) tcp->sock); |
| 134 | return 1; | 134 | return 1; |
| 135 | } | 135 | } |
| 136 | 136 | ||
| @@ -164,6 +164,7 @@ static int meth_accept(lua_State *L) | |||
| 164 | p_tcp clnt = lua_newuserdata(L, sizeof(t_tcp)); | 164 | p_tcp clnt = lua_newuserdata(L, sizeof(t_tcp)); |
| 165 | aux_setclass(L, "tcp{client}", -1); | 165 | aux_setclass(L, "tcp{client}", -1); |
| 166 | /* initialize structure fields */ | 166 | /* initialize structure fields */ |
| 167 | sock_setnonblocking(&sock); | ||
| 167 | clnt->sock = sock; | 168 | clnt->sock = sock; |
| 168 | io_init(&clnt->io, (p_send)sock_send, (p_recv)sock_recv, &clnt->sock); | 169 | io_init(&clnt->io, (p_send)sock_send, (p_recv)sock_recv, &clnt->sock); |
| 169 | tm_init(&clnt->tm, -1, -1); | 170 | tm_init(&clnt->tm, -1, -1); |
| @@ -310,10 +311,11 @@ static int global_create(lua_State *L) | |||
| 310 | if (!err) { | 311 | if (!err) { |
| 311 | /* allocate tcp object */ | 312 | /* allocate tcp object */ |
| 312 | p_tcp tcp = (p_tcp) lua_newuserdata(L, sizeof(t_tcp)); | 313 | p_tcp tcp = (p_tcp) lua_newuserdata(L, sizeof(t_tcp)); |
| 313 | tcp->sock = sock; | ||
| 314 | /* set its type as master object */ | 314 | /* set its type as master object */ |
| 315 | aux_setclass(L, "tcp{master}", -1); | 315 | aux_setclass(L, "tcp{master}", -1); |
| 316 | /* initialize remaining structure fields */ | 316 | /* initialize remaining structure fields */ |
| 317 | sock_setnonblocking(&sock); | ||
| 318 | tcp->sock = sock; | ||
| 317 | io_init(&tcp->io, (p_send) sock_send, (p_recv) sock_recv, &tcp->sock); | 319 | io_init(&tcp->io, (p_send) sock_send, (p_recv) sock_recv, &tcp->sock); |
| 318 | tm_init(&tcp->tm, -1, -1); | 320 | tm_init(&tcp->tm, -1, -1); |
| 319 | buf_init(&tcp->buf, &tcp->io, &tcp->tm); | 321 | buf_init(&tcp->buf, &tcp->io, &tcp->tm); |
