This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

nRF9160 select() always returns 115

I have an nRF9160 with nrfx v2.5.0 and nrfxlib v1.5.1. We have integrated nrf_modem into our own OS. I would like to use TCP sockets asynchronously, but cannot establish a nonblocking connection.

I can establish a TCP connection to our server while blocking with no issues. I suspect I'm also getting a successful connection to the server in the nonblocking case too, but I cannot find a way to determine if the connection has been established.

I have tried polling on nrf_getsockopt(sock, NRF_SOL_SOCKET, NRF_SO_ERROR... ). This works in the case where the server disconnects (i.e. I get an error code), but there is nothing to indicate a successful connection.

The standard posix way of doing this would be to call select() and wait for writing to come available. No matter what I do, nrf_select() always returns 115 (EINPROGRESS), and does so immediately after calling.

I would expect that even if I were doing something wrong, the following would run until it timed out:

nrf_select(sock + 1, NULL, NULL, NULL, &tv);

but this also returns immediately with 115. I suspect that there is a subtlety in the API that I am missing.

Procedure overview:

  • nrf_fcntl(sock, NRF_F_GETFL, 0);
  • nrf_fcntl(sock, NRF_F_SETFL, res | NRF_O_NONBLOCK);
  • nrf_connect(sock, &zzz, sizeof(zzz));
  • nrf_select(sock + 1, NULL, &fdset, NULL, &tv); - returns 115, no matter  what I do with the arguments. I am using NRF_FD_ZERO, NRF_FD_SET.
  • nrf_getsockopt(sock, NRF_SOL_SOCKET, NRF_SO_ERROR, ...); - tells me when the link goes down but not when the connection is successful.

TLDR: The root issue I am trying to solve is: how do I determine that my NONBLOCKING nrf_connect() has successfully connected with nrf_modem. I would also like to know what is going wrong with nrf_select() that is preventing me from using it, but this is less important.

Parents
  • Hello Gareth,

    I just found out that nrf_select() is not supported yet within our implementation neither.

    You might wanna have a look at the Zephyr implantation of the select() function and implement it to your OS?

    However, that implementation is more of a "prosthesis" to make existing applications that require select() work and it is suggested to use poll() directly instead. But this might be something that you are already doing now?

    Regards,

    Markus

Reply
  • Hello Gareth,

    I just found out that nrf_select() is not supported yet within our implementation neither.

    You might wanna have a look at the Zephyr implantation of the select() function and implement it to your OS?

    However, that implementation is more of a "prosthesis" to make existing applications that require select() work and it is suggested to use poll() directly instead. But this might be something that you are already doing now?

    Regards,

    Markus

Children
No Data
Related