Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

With TCP, modbus_connect() returns -1 on timeout but does not set errno #736

Closed
kyllingstad opened this issue Jan 29, 2024 · 0 comments
Closed

Comments

@kyllingstad
Copy link
Contributor

libmodbus version

3f9f17e (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 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:

        rc = select(sockfd + 1, NULL, &wset, NULL, &tv);
        if (rc <= 0) {
            /* Timeout or fail */
            return -1;
        }

Expected behavior or suggestion

errno == ETIMEDOUT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant