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

wait_readable returns 0 instead of NSAPI_ERROR_WOULD_BLOCK #10

Open
strange-v opened this issue Jan 11, 2020 · 1 comment
Open

wait_readable returns 0 instead of NSAPI_ERROR_WOULD_BLOCK #10

strange-v opened this issue Jan 11, 2020 · 1 comment

Comments

@strange-v
Copy link
Contributor

According to the Mbed documentation socket.recv method should return NSAPI_ERROR_WOULD_BLOCK in case it non-blocking or timeout.

But if we check the code we can see that it returns size in case of timeout (zero in many cases).

        if ((size1 > req_size) || (wait_time_ms != (-1) && t.read_ms() > wait_time_ms)) 
        {
            return size1;
        }
    }
    return NSAPI_ERROR_WOULD_BLOCK;

It seems incorrect. Am I wrong?

@strange-v
Copy link
Contributor Author

After further investigation, I've found one more issue in this piece of code.
Even if "wait_readable" returns NSAPI_ERROR_WOULD_BLOCK, "WIZnetInterface::socket_recv" returns zero, because recved_size is always zero in this case.

Either recved_size should be declared like this
int recved_size = -1;
or condition should be
if(recved_size > 0){

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