Use non-blocking socket (fcntl(sockfd, F_SETFL, O_NONBLOCK);) with select and/or a separate thread
Use non-blocking socket (fcntl(sockfd, F_SETFL, O_NONBLOCK);) with select and/or a separate thread