aboutsummaryrefslogtreecommitdiff
path: root/src/udp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/udp.c')
-rw-r--r--src/udp.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/udp.c b/src/udp.c
index 13007fb..386051a 100644
--- a/src/udp.c
+++ b/src/udp.c
@@ -184,6 +184,9 @@ static int meth_receive(lua_State *L) {
184 count = MIN(count, sizeof(buffer)); 184 count = MIN(count, sizeof(buffer));
185 timeout_markstart(tm); 185 timeout_markstart(tm);
186 err = socket_recv(&udp->sock, buffer, count, &got, tm); 186 err = socket_recv(&udp->sock, buffer, count, &got, tm);
187 /* Unlike TCP, recv() of zero is not closed, but a zero-length packet. */
188 if (err == IO_CLOSED)
189 err = IO_DONE;
187 if (err != IO_DONE) { 190 if (err != IO_DONE) {
188 lua_pushnil(L); 191 lua_pushnil(L);
189 lua_pushstring(L, udp_strerror(err)); 192 lua_pushstring(L, udp_strerror(err));
@@ -208,6 +211,9 @@ static int meth_receivefrom(lua_State *L) {
208 count = MIN(count, sizeof(buffer)); 211 count = MIN(count, sizeof(buffer));
209 err = socket_recvfrom(&udp->sock, buffer, count, &got, 212 err = socket_recvfrom(&udp->sock, buffer, count, &got,
210 (SA *) &addr, &addr_len, tm); 213 (SA *) &addr, &addr_len, tm);
214 /* Unlike TCP, recv() of zero is not closed, but a zero-length packet. */
215 if (err == IO_CLOSED)
216 err = IO_DONE;
211 if (err == IO_DONE) { 217 if (err == IO_DONE) {
212 lua_pushlstring(L, buffer, got); 218 lua_pushlstring(L, buffer, got);
213 lua_pushstring(L, inet_ntoa(addr.sin_addr)); 219 lua_pushstring(L, inet_ntoa(addr.sin_addr));