diff --git a/src/modbus-tcp.c b/src/modbus-tcp.c index d808d56..8389eae 100644 --- a/src/modbus-tcp.c +++ b/src/modbus-tcp.c @@ -556,8 +556,7 @@ int modbus_tcp_listen(modbus_t *ctx, int nb_connection) if (ctx->debug) { fprintf(stderr, "Invalid IP address: %s\n", ctx_tcp->ip); } - close(ctx->s); - ctx->s = -1; + close(new_s); return -1; } }