This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

poll() not blocking

Hello,

I am using the Nordic SDK v1.5.0, the modem firmware is mfw_nrf9160_1.2.3 and the DK for the nRF9160

In our application, we are using AT commands to setup and control the modem. On startup, the modem PSM and eDRX

features are switched off to prevent a disconnection due to power saving features. Then we open a TCP listening socket and

wait, on a separate thread, for remote clients to connect. This thread also reads data from connected clients, and uses poll() to

block and wait for events, as follows:

struct pollfd pollSet[SOCKET_ID_MAX]; 

pollSet[SOCKET_ID_CLIENT].fd = Sockets[SOCKET_ID_CLIENT];
pollSet[SOCKET_ID_CLIENT].events = POLLIN;

pollSet[SOCKET_ID_SERVER].fd = Sockets[SOCKET_ID_SERVER];
pollSet[SOCKET_ID_SERVER].events = POLLIN;

// should block forever, until a client connects or a 
// connected client has sent data
if (0 < poll(pollSet,SOCKET_ID_MAX,-1))
{
    // sockets handling code
}

Initially only the listening socket is open. However the poll() call never blocks, instead  it returns immediately

with the server socket revents field set to zero ( = no events). I cannot understand why, it should block for

an wait incomming client connection.

For reference, these are the configuration I am using:

# Zephyr OS Network
CONFIG_NETWORKING=y
CONFIG_NET_NATIVE=n
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_OFFLOAD=y

# Nordic Libraries
CONFIG_NRF_MODEM_LIB=y
CONFIG_LTE_LINK_CONTROL=n
CONFIG_LTE_AUTO_INIT_AND_CONNECT=n

Related