From da9bd55e06e0820bf0ed2f2eaf3fd12af91f717c Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Mon, 4 Mar 2019 15:27:01 +0900 Subject: [PATCH] Add check for no pkt received (non-blocking) --- src/UDPConnection.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/UDPConnection.c b/src/UDPConnection.c index 609cddc..50b61f8 100644 --- a/src/UDPConnection.c +++ b/src/UDPConnection.c @@ -4,6 +4,7 @@ #include #include #include +#include UDPC_Context* UDPC_init(uint16_t listenPort, int isClient) { @@ -460,6 +461,13 @@ void UDPC_update(UDPC_Context *ctx) 0, (struct sockaddr*) &receivedData, &receivedDataSize); + + if(bytes == 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) + { + // expected result for non-blocking socket + return; + } + if(bytes < 20) { UDPC_INTERNAL_log(ctx, 2, "Got invalid packet from %s port %d (too small)",