I'm running this piece of code several times (for a non-blocking recvfrom
on a UDP socket):
struct timeval read_timeout;
read_timeout.tv_sec = 0;
read_timeout.tv_usec = 1000;
setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &read_timeout, sizeof read_timeout);
ssize_t n = recvfrom(sockfd, recvline, sizeof(recvline), 0, NULL, NULL);
if (n < 0) {
perror("recvfrom");
return -1;
} else // ... normal usage
Sometimes the program stops and I get the following error from perror
recvfrom: Resource temporarily unavailable
What could the issue be?