From e2c9f5fd4f6e94effdec1938c3f2e37bdc604e84 Mon Sep 17 00:00:00 2001 From: Stéphane Raimbault Date: Wed, 4 May 2011 00:14:12 +0200 Subject: [PATCH] Fix flush function of TCP backend on Windows --- src/modbus-tcp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modbus-tcp.c b/src/modbus-tcp.c index 1f5d453..01661e9 100644 --- a/src/modbus-tcp.c +++ b/src/modbus-tcp.c @@ -346,7 +346,10 @@ int _modbus_tcp_flush(modbus_t *ctx) return -1; } - rc = recv(ctx->s, devnull, MODBUS_TCP_MAX_ADU_LENGTH, 0); + if (rc == 1) { + /* There is data to flush */ + rc = recv(ctx->s, devnull, MODBUS_TCP_MAX_ADU_LENGTH, 0); + } #endif if (ctx->debug && rc != -1) { printf("\n%d bytes flushed\n", rc); -- libgit2 0.21.4