![]() |
nrfxlib API 3.3.99
|
| #define NRF_SO_KEEPOPEN 34 |
#include <nrf_modem/include/nrf_socket.h>
Keep the socket open when its PDN connection is lost, or the device is set to flight mode.
This option keeps a socket from being closed upon PDN disconnection or reactivation events, or when the device is set to flight mode (+CFUN=4). Until the PDN connection is reestablished, the socket is not functional.
Output operations, such as the functions nrf_send and nrf_connect return an error and set errno to NRF_ENETUNREACH.
Input operations, such as the functions nrf_recv and nrf_accept block, since no data can be received, or return an error if the socket or the operation is non-blocking.
Upon PDN connection reestablishment, the socket behavior depends on the socket type and protocol and on the IP address of the socket's newly established PDN connection, as shown in the following table:
| Socket type | Socket protocol | Socket is functional (no errors) |
|---|---|---|
| NRF_SOCK_DGRAM | NRF_IPPROTO_UDP | Always |
| NRF_SOCK_DGRAM | NRF_SPROTO_DTLS1v2 | If using DTLS connection ID |
| NRF_SOCK_STREAM | NRF_IPPROTO_TCP | If the socket PDN IP address has not changed |
| NRF_SOCK_STREAM | NRF_SPROTO_TLS1v2 | If the socket PDN IP address has not changed |
| NRF_SOCK_RAW | Any | Always |
If the conditions to keep the socket open after PDN connection reestablishment are not met, the socket will report an error (and set errno to NRF_ENETDOWN), and must be closed by the application. Otherwise, the socket is functional, and the application can use it.
0 (+CFUN=0) always forces all sockets to be closed, regardless of the NRF_SO_KEEPOPEN socket option.