LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   missign error return from readfrom (https://www.linuxquestions.org/questions/programming-9/missign-error-return-from-readfrom-266596/)

vadiml 12-15-2004 05:30 AM

missign error return from readfrom
 
Hello,

I'm using sendto call to send data from app1 to app2 to running on same (or sometimes different machine).... and doing recvfrom to read a responce

I've read inte linux man pages, that if there is no application on the listening on destination port
the sending socket is marked so when i do recvfrom i'm supposed get a -1 ret value and error number in the errno....

so i'm shutting down the app2, and causing app1 send the data.... I see in ethereal the ICMP port unreachable message comming back in answer to the data packet....

but recvfrom does not getting an error code.... i've tried to do select with error fd_set nonempty
and select simply sits waiting there ad infinitum....


Any ideas what i'm doing wrong, i really want to avoid to use some kind of heartbeat protocol to detetct missing remote application....


Thanks

Vadim

yrraja 12-15-2004 07:02 AM

It seems u r using UDP for your communication. In UDP u normally dont get back ICMP errors.. this is why although ur machine receives ICMP port unreachable message it is not communicated back to u.

You should either use TCP or u should use 'connected UDP'. U can find more information on this from Richard Stevens book "Unix Network Programming"

vadiml 12-15-2004 10:59 AM

Thanks for the reply,

You're right i'm using UDP, but this stuff should work and actually works with UDP too...
After browsing linux kernel, i've found that after i use 'connect' api on the socket, the kernel will report an error on 'recv' following the ICMP message reception


Thanks
Vadim


All times are GMT -5. The time now is 08:57 AM.