Hi,
In our application, we need the TCP/UDP socket keeps alive even when its receiving is timeout. so we changed the process code in do_tcp_receive() and do_udp_recvfrom() to below:
if (ret < 0) { LOG_WRN("recv() error: %d", -errno); //do_socket_close(-errno); ret = -errno; } else if (ret == 0) { /** * When a stream socket peer has performed an orderly shutdown, * the return value will be 0 (the traditional "end-of-file") * The value 0 may also be returned if the requested number of * bytes to receive from a stream socket was 0 * In both cases, treat as normal shutdown by remote */ LOG_WRN("recv() return 0"); //do_socket_close(0); } else {
After receive timeout(Log output: recv() error: -60), we found the next receive or send will be not available.
In this situation, how to continue to receive and send without closing and recreating the socket?