From 7af01881e27f8a876c1231cafd1741631581d079 Mon Sep 17 00:00:00 2001 From: Eric Blankenhorn Date: Mon, 11 Nov 2024 09:11:13 -0600 Subject: [PATCH] Handle connection error in mqttsimple client --- examples/mqttsimple/mqttsimple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/mqttsimple/mqttsimple.c b/examples/mqttsimple/mqttsimple.c index b0f4777d..e7a7b086 100644 --- a/examples/mqttsimple/mqttsimple.c +++ b/examples/mqttsimple/mqttsimple.c @@ -229,7 +229,7 @@ static int mqtt_net_read(void *context, byte* buf, int buf_len, int timeout_ms) /* Loop until buf_len has been read, error or timeout */ while (bytes < buf_len) { rc = (int)recv(*pSockFd, &buf[bytes], buf_len - bytes, 0); - if (rc < 0) { + if (rc <= 0) { rc = socket_get_error(*pSockFd); if (rc == 0) break; /* timeout */