diff options
author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-05-28 07:24:43 +0000 |
---|---|---|
committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-05-28 07:24:43 +0000 |
commit | c98dc991998c724a3f6a1fdd90b5d1d8a80e3af3 (patch) | |
tree | 8d8b8aa856d8a3e822121d0915a63b8244f471bb /src/udp.c | |
parent | 9297b074d53a00e1149250e0bbfa0871dcc5558f (diff) | |
download | luasocket-c98dc991998c724a3f6a1fdd90b5d1d8a80e3af3.tar.gz luasocket-c98dc991998c724a3f6a1fdd90b5d1d8a80e3af3.tar.bz2 luasocket-c98dc991998c724a3f6a1fdd90b5d1d8a80e3af3.zip |
Bug feioso no UDP e possivelmente no TCP também.
Diffstat (limited to 'src/udp.c')
-rw-r--r-- | src/udp.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -109,7 +109,8 @@ static int meth_send(lua_State *L) | |||
109 | int err; | 109 | int err; |
110 | const char *data = luaL_checklstring(L, 2, &count); | 110 | const char *data = luaL_checklstring(L, 2, &count); |
111 | tm_markstart(tm); | 111 | tm_markstart(tm); |
112 | err = sock_send(&udp->sock, data, count, &sent, tm_get(tm)); | 112 | do err = sock_send(&udp->sock, data, count, &sent, tm_getretry(tm)); |
113 | while (err == IO_RETRY); | ||
113 | if (err == IO_DONE) lua_pushnumber(L, sent); | 114 | if (err == IO_DONE) lua_pushnumber(L, sent); |
114 | else lua_pushnil(L); | 115 | else lua_pushnil(L); |
115 | /* a 'closed' error on an unconnected means the target address was not | 116 | /* a 'closed' error on an unconnected means the target address was not |
@@ -137,8 +138,9 @@ static int meth_sendto(lua_State *L) | |||
137 | addr.sin_family = AF_INET; | 138 | addr.sin_family = AF_INET; |
138 | addr.sin_port = htons(port); | 139 | addr.sin_port = htons(port); |
139 | tm_markstart(tm); | 140 | tm_markstart(tm); |
140 | err = sock_sendto(&udp->sock, data, count, &sent, | 141 | do err = sock_sendto(&udp->sock, data, count, &sent, |
141 | (SA *) &addr, sizeof(addr), tm_get(tm)); | 142 | (SA *) &addr, sizeof(addr), tm_get(tm)); |
143 | while (err == IO_RETRY); | ||
142 | if (err == IO_DONE) lua_pushnumber(L, sent); | 144 | if (err == IO_DONE) lua_pushnumber(L, sent); |
143 | else lua_pushnil(L); | 145 | else lua_pushnil(L); |
144 | /* a 'closed' error on an unconnected means the target address was not | 146 | /* a 'closed' error on an unconnected means the target address was not |
@@ -159,7 +161,8 @@ static int meth_receive(lua_State *L) | |||
159 | p_tm tm = &udp->tm; | 161 | p_tm tm = &udp->tm; |
160 | count = MIN(count, sizeof(buffer)); | 162 | count = MIN(count, sizeof(buffer)); |
161 | tm_markstart(tm); | 163 | tm_markstart(tm); |
162 | err = sock_recv(&udp->sock, buffer, count, &got, tm_get(tm)); | 164 | do err = sock_recv(&udp->sock, buffer, count, &got, tm_get(tm)); |
165 | while (err == IO_RETRY); | ||
163 | if (err == IO_DONE) lua_pushlstring(L, buffer, got); | 166 | if (err == IO_DONE) lua_pushlstring(L, buffer, got); |
164 | else lua_pushnil(L); | 167 | else lua_pushnil(L); |
165 | io_pusherror(L, err); | 168 | io_pusherror(L, err); |
@@ -180,8 +183,9 @@ static int meth_receivefrom(lua_State *L) | |||
180 | p_tm tm = &udp->tm; | 183 | p_tm tm = &udp->tm; |
181 | tm_markstart(tm); | 184 | tm_markstart(tm); |
182 | count = MIN(count, sizeof(buffer)); | 185 | count = MIN(count, sizeof(buffer)); |
183 | err = sock_recvfrom(&udp->sock, buffer, count, &got, | 186 | do err = sock_recvfrom(&udp->sock, buffer, count, &got, |
184 | (SA *) &addr, &addr_len, tm_get(tm)); | 187 | (SA *) &addr, &addr_len, tm_get(tm)); |
188 | while (err == IO_RETRY); | ||
185 | if (err == IO_DONE) { | 189 | if (err == IO_DONE) { |
186 | lua_pushlstring(L, buffer, got); | 190 | lua_pushlstring(L, buffer, got); |
187 | lua_pushstring(L, inet_ntoa(addr.sin_addr)); | 191 | lua_pushstring(L, inet_ntoa(addr.sin_addr)); |