flashburn
flashburn

Reputation: 4538

Resource temporarily unavailable, UDP socket

I'm talking to a device over a UDP socket. I send a command and then receive a response from it. The messages need to be sent every 100ms. I set a receive timeout with

struct timeval t = {.tv_sec = 0, .tv_usec = 100000};
setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, t, sizeof(t));

where fd is my socket file descriptor. Everything works fine for a long time but then I start getting a Resource temporarily unavailable error on the recvfrom(...) call. As far as I understand it happens because there is nothing in the receive buffer. I would be expecting that on the next iteration the buffer would be full, but I'm still getting Resource temporarily unavailable. In other words the system doesn't recover. Is that an issue with a socket itself, the settings on the socket, or the device?

Upvotes: 0

Views: 1601

Answers (1)

mshamory
mshamory

Reputation: 84

There shouldn't be an issue with the socket or its configuration if you are getting traffic initially. You would see a different error message if that was the case.

If you're only encountering the message once or twice in a row, it could be network delay or packet loss due to some networking issue. (e.g. a bad switch, slow network connection, etc.)

If you consistently encountering the message (each time recvfrom is called) there may be an issue with the connection between the client and server. I would verify that the client is still sending messages and check your network connection.

Upvotes: 0

Related Questions