aboutsummaryrefslogtreecommitdiff
path: root/src/wsocket.c
diff options
context:
space:
mode:
authorThijs Schreijer <thijs@thijsschreijer.nl>2026-08-30 12:58:43 +0200
committerThijs Schreijer <thijs@thijsschreijer.nl>2026-08-30 13:46:21 +0200
commit75d638ac9cc613f39ec4513d3dc2e43a6f909da1 (patch)
treee883e854605945a839f208d1ab36c2ae9d20cc1d /src/wsocket.c
parente21720da69f2a505bcd1405cc7e8b52d5649df55 (diff)
downloadluasocket-75d638ac9cc613f39ec4513d3dc2e43a6f909da1.tar.gz
luasocket-75d638ac9cc613f39ec4513d3dc2e43a6f909da1.tar.bz2
luasocket-75d638ac9cc613f39ec4513d3dc2e43a6f909da1.zip
fix(udp): receive(0) tests and bad call to getnameinfo
Diffstat (limited to 'src/wsocket.c')
-rw-r--r--src/wsocket.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/wsocket.c b/src/wsocket.c
index 86c6994..b2b668c 100644
--- a/src/wsocket.c
+++ b/src/wsocket.c
@@ -286,6 +286,14 @@ int socket_recvfrom(p_socket ps, char *data, size_t count, size_t *got,
286 } 286 }
287 if (taken == 0) return IO_CLOSED; 287 if (taken == 0) return IO_CLOSED;
288 err = WSAGetLastError(); 288 err = WSAGetLastError();
289 /* a zero-length request is trivially "too small" for any
290 * non-empty datagram; unlike POSIX, which truncates and succeeds
291 * silently, Windows reports this as WSAEMSGSIZE even though the
292 * datagram -- and its sender's address, already written to addr/
293 * len above -- was still consumed. Normalize it to match POSIX's
294 * silent-truncation instead of surfacing a platform-specific
295 * error for what is otherwise a successful, if empty, receive. */
296 if (count == 0 && err == WSAEMSGSIZE) return IO_DONE;
289 /* On UDP, a connreset simply means the previous send failed. 297 /* On UDP, a connreset simply means the previous send failed.
290 * So we try again. 298 * So we try again.
291 * On TCP, it means our socket is now useless, so the error passes. 299 * On TCP, it means our socket is now useless, so the error passes.