From: Stephen Seo Date: Mon, 4 Mar 2019 06:27:01 +0000 (+0900) Subject: Add check for no pkt received (non-blocking) X-Git-Tag: 1.0~233 X-Git-Url: https://git.seodisparate.com/stephenseo/client_config?a=commitdiff_plain;h=da9bd55e06e0820bf0ed2f2eaf3fd12af91f717c;p=UDPConnection Add check for no pkt received (non-blocking) --- 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)",