I am running CoAP client with DTLS enabled on an nRF9161dk.
I poll socket using this code:
while (1) { if (!socket_ready) { k_msleep(100); continue; } /* Poll socket */ err = poll(&fds, 1, 0); if (err < 0) { LOG_ERR("Poll error: %d", errno); continue; } if (fds.revents & POLLHUP) { LOG_ERR("POLLHUP"); continue; } if (fds.revents & POLLERR) { LOG_ERR("POLLERR"); continue; } if (fds.revents & POLLNVAL) { LOG_ERR("POLLNVAL"); continue; } /* Handle data */ if (fds.revents & POLLIN) { LOG_ERR("POLLIN"); received = recv(sock, coap_buf, sizeof(coap_buf), 0); if (received < 0) { LOG_ERR("Socket error: %d, exit\n", errno); continue; // break; } else if (received == 0) { LOG_ERR("Empty datagram\n"); continue; } LOG_INF("Packet received, proceeding to handling\n"); err = client_handle_response(coap_buf, received); if (err < 0) { LOG_ERR("Invalid response, exit\n"); break; } } k_msleep(10); }
I am able to receive data (POLLIN), but when server closes session and sends close_notify, I am not able to receive POLLHUP.
I've tried nRF SDK 2.6.1 and 2.7.0. Modem FW version: mfw_nrf91x1_2.0.1.
Has anyone else encountered this problem?