Reputation: 4595
I am trying out a udpclient program which uses sendto and recvfrom functions. I am setting SO_RCVTIMEO value as 10 seconds for my socket.
I am binding the socket to source ipaddress and sourceport. When I check the netstat I can see that there is no other process which is binded with the same values. My bind operation is also successfull.
Then I am doing a sendto which is sending a echo request to destination. After sendto I am doing a recvfrom. But recvfrom fail's saying ERRNO 11 which means try again :(
But if I check the wireshark logs I can see ECHO REQUEST and ECHO REPLY which is coming within few milliseconds but still recvfrom is not able to read it :(. In wireshark I am seeing the UDP ECHO REQUEST AND UDP ECHO REPLY.
I dont have any FIREWALL enabled in my system.
Is there any way to debug this issue :( I am really doubting the RECV operation is there any way to find out if the packet is being sent to my sockFD or not ???
UPDATE1: My linux PC is connected to another linux pc acting as a server via switch.
Upvotes: 3
Views: 9229
Reputation: 4595
I have the found out the ISSUE atlast ...
Seems UDP checksum of the packet is wrong as a result IP STACK is dropping the packet before it reach's SOCKET :( as a result recvfrom is getting timeout and coming out.
Upvotes: 2
Reputation: 239041
EAGAIN
from recvfrom()
implies one of three things:
MSG_DONTWAIT
flag was used; orIt sounds like your socket is non-blocking to me.
Upvotes: 1