Windows (but I believe the problem also exists on *NIX)
Environment
N/A
Description
With TCP, modbus_connect() returns -1 on timeout, but does not set errno.
The reason seems to be that the timeout is implemented via select(), where a timeout is not considered an error. The offending code is in lines 295–299 of modbus-tcp.c, which look like this:
libmodbus version
3f9f17e228f70ce2fcdc1988cf7563fc1bf78eec (current
master
)OS and/or distribution
Windows (but I believe the problem also exists on *NIX)
Environment
N/A
Description
With TCP,
modbus_connect()
returns -1 on timeout, but does not seterrno
.The reason seems to be that the timeout is implemented via
select()
, where a timeout is not considered an error. The offending code is in lines 295–299 ofmodbus-tcp.c
, which look like this:Expected behavior or suggestion
errno == ETIMEDOUT