aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/udp.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/udp.c b/src/udp.c
index e604bea..8168bf2 100644
--- a/src/udp.c
+++ b/src/udp.c
@@ -170,6 +170,9 @@ static int meth_receive(lua_State *L) {
170 count = MIN(count, sizeof(buffer)); 170 count = MIN(count, sizeof(buffer));
171 timeout_markstart(tm); 171 timeout_markstart(tm);
172 err = socket_recv(&udp->sock, buffer, count, &got, tm); 172 err = socket_recv(&udp->sock, buffer, count, &got, tm);
173 /* Unlike TCP, recv() of zero is not closed, but a zero-length packet. */
174 if (err == IO_CLOSED)
175 err = IO_DONE;
173 if (err != IO_DONE) { 176 if (err != IO_DONE) {
174 lua_pushnil(L); 177 lua_pushnil(L);
175 lua_pushstring(L, udp_strerror(err)); 178 lua_pushstring(L, udp_strerror(err));
@@ -194,6 +197,9 @@ static int meth_receivefrom(lua_State *L) {
194 count = MIN(count, sizeof(buffer)); 197 count = MIN(count, sizeof(buffer));
195 err = socket_recvfrom(&udp->sock, buffer, count, &got, 198 err = socket_recvfrom(&udp->sock, buffer, count, &got,
196 (SA *) &addr, &addr_len, tm); 199 (SA *) &addr, &addr_len, tm);
200 /* Unlike TCP, recv() of zero is not closed, but a zero-length packet. */
201 if (err == IO_CLOSED)
202 err = IO_DONE;
197 if (err == IO_DONE) { 203 if (err == IO_DONE) {
198 lua_pushlstring(L, buffer, got); 204 lua_pushlstring(L, buffer, got);
199 lua_pushstring(L, inet_ntoa(addr.sin_addr)); 205 lua_pushstring(L, inet_ntoa(addr.sin_addr));