I have a client and a server communicating with datagrams (UDP) in C. The client sends 5 msgs and upon receiving msgs, server sends msgs back. Receiving and sending messages are great until client has finished receiving the msgs. After server sending all msgs back, it terminates using close(). so recvfrom() from client should return 0, right?
Assuming recvfrom() should return 0 upon close() from server side, it returns -1 instead, with error Resource temporarily unavailable. Is this resource reference to closed socket from server? Or is it for something else entirely different like running out of buffer or something (which i don't think is true)?
Assuming my assumption was wrong and -1 is returned because server terminated, I probably should handle the error with
if(SOMEMACRO)
do something
How do I find out what SOMEMACRO
is? I print out the error but it says resource temp unavailable and recvfrom() description doesn't mention about unavilable resource..?
Btw, this is a non blocking socket, if that makes any difference since i read that if O_NONBLOCK is set and no msgs are available, it would set errno to EAGAIN or EWOULDBLOCK. O_NONBLOCK isn't set but MSG_DONTWAIT is set. Are they basically the same thing where O_NONBLOCK is for general file descriptors and MSG_DONTWAIT is socket specific??
My brain isn't working all that great now, if someone could enlighten me and clarify what my confusion is about, i would deeply appreciate it. Thanks!