Add check for no pkt received (non-blocking)
This commit is contained in:
parent
d38c7ac105
commit
da9bd55e06
1 changed files with 8 additions and 0 deletions
|
@ -4,6 +4,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
UDPC_Context* UDPC_init(uint16_t listenPort, int isClient)
|
UDPC_Context* UDPC_init(uint16_t listenPort, int isClient)
|
||||||
{
|
{
|
||||||
|
@ -460,6 +461,13 @@ void UDPC_update(UDPC_Context *ctx)
|
||||||
0,
|
0,
|
||||||
(struct sockaddr*) &receivedData,
|
(struct sockaddr*) &receivedData,
|
||||||
&receivedDataSize);
|
&receivedDataSize);
|
||||||
|
|
||||||
|
if(bytes == 0 && (errno == EAGAIN || errno == EWOULDBLOCK))
|
||||||
|
{
|
||||||
|
// expected result for non-blocking socket
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(bytes < 20)
|
if(bytes < 20)
|
||||||
{
|
{
|
||||||
UDPC_INTERNAL_log(ctx, 2, "Got invalid packet from %s port %d (too small)",
|
UDPC_INTERNAL_log(ctx, 2, "Got invalid packet from %s port %d (too small)",
|
||||||
|
|
Loading…
Reference in a new issue