Killed a few bugs found by Tomas.
This commit is contained in:
parent
9bc4e0648a
commit
3febb302ad
10 changed files with 99 additions and 58 deletions
|
@ -100,7 +100,7 @@ static int meth_send(lua_State *L)
|
|||
int err;
|
||||
const char *data = luaL_checklstring(L, 2, &count);
|
||||
tm_markstart(tm);
|
||||
err = sock_send(&udp->sock, data, count, &sent, tm_get(tm));
|
||||
err = sock_send(&udp->sock, data, count, &sent, tm_getsuccess(tm));
|
||||
if (err == IO_DONE) lua_pushnumber(L, sent);
|
||||
else lua_pushnil(L);
|
||||
/* a 'closed' error on an unconnected means the target address was not
|
||||
|
@ -129,7 +129,7 @@ static int meth_sendto(lua_State *L)
|
|||
addr.sin_port = htons(port);
|
||||
tm_markstart(tm);
|
||||
err = sock_sendto(&udp->sock, data, count, &sent,
|
||||
(SA *) &addr, sizeof(addr), tm_get(tm));
|
||||
(SA *) &addr, sizeof(addr), tm_getsuccess(tm));
|
||||
if (err == IO_DONE) lua_pushnumber(L, sent);
|
||||
else lua_pushnil(L);
|
||||
/* a 'closed' error on an unconnected means the target address was not
|
||||
|
@ -150,7 +150,7 @@ static int meth_receive(lua_State *L)
|
|||
p_tm tm = &udp->tm;
|
||||
count = MIN(count, sizeof(buffer));
|
||||
tm_markstart(tm);
|
||||
err = sock_recv(&udp->sock, buffer, count, &got, tm_get(tm));
|
||||
err = sock_recv(&udp->sock, buffer, count, &got, tm_getsuccess(tm));
|
||||
if (err == IO_DONE) lua_pushlstring(L, buffer, got);
|
||||
else lua_pushnil(L);
|
||||
io_pusherror(L, err);
|
||||
|
@ -172,7 +172,7 @@ static int meth_receivefrom(lua_State *L)
|
|||
tm_markstart(tm);
|
||||
count = MIN(count, sizeof(buffer));
|
||||
err = sock_recvfrom(&udp->sock, buffer, count, &got,
|
||||
(SA *) &addr, &addr_len, tm_get(tm));
|
||||
(SA *) &addr, &addr_len, tm_getsuccess(tm));
|
||||
if (err == IO_DONE) {
|
||||
lua_pushlstring(L, buffer, got);
|
||||
lua_pushstring(L, inet_ntoa(addr.sin_addr));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue