I created a UDP socket because the socket is going to be connectionless (i.e. no call to connect() on the socket). I want a non-blocking socket so I added this code:
if(fcntl(sockfd, F_SETFL, O_NONBLOCK) < 0) {
perror("fcntl()"
exit(0);
}
This is great; however, it turns out that you can not use a non-blocking socket when using the recvfrom() function. You receive an error message something like this:
"Resource temporarily unavailable", which corresponds to errno code "EAGAIN", which means that a client tried to use recvfrom() on a non-blocking socket when no data was available for reading. I thought that was the whole point! Of course there isn't any data "right now" - that is the reason I made the socket non-blocking, so I could handle other events. How am I supposed to do this?
Thanks,
-bitwise
if(fcntl(sockfd, F_SETFL, O_NONBLOCK) < 0) {
perror("fcntl()"
exit(0);
}
This is great; however, it turns out that you can not use a non-blocking socket when using the recvfrom() function. You receive an error message something like this:
"Resource temporarily unavailable", which corresponds to errno code "EAGAIN", which means that a client tried to use recvfrom() on a non-blocking socket when no data was available for reading. I thought that was the whole point! Of course there isn't any data "right now" - that is the reason I made the socket non-blocking, so I could handle other events. How am I supposed to do this?
Thanks,
-bitwise