"be consistent" | |
PerlMonks |
send call on udp socketby saurabh.hirani (Beadle) |
on May 04, 2009 at 15:28 UTC ( [id://761747]=perlquestion: print w/replies, xml ) | Need Help?? |
saurabh.hirani has asked for the wisdom of the Perl Monks concerning the following question: Hi guys, I am writing a udp client-server system and during the work I found a problem which I wanted to discuss with you. It is best explained through this snippet:
If there is no server on 3333, the output is pretty interesting:
AFAIK, the reason why this would happen would be - in UDP the send system call cannot return the send status of the message as it is a blind throw. So if the message is within limits, the socket is okay, send returns true. When the message is transmitted, if the host is not up we get a "connection refused" icmp error, which is captured in any of the sending/receiving operations I do later on and I get an error - the first send returned immediately after checking if the message can be sent. It can be. So after the first send and before the second, ICMP host not found was sent back. So the second send failed. Similarly it goes for the 3rd and 4th and so on. My question: How would you check the status of send sys call if you had to log an error if the host is down or something? (And no I don't want to use TCP :) ) - I was thinking of using Net::Ping module. The output becomes all the more interesting if I configure a rule in iptables, telling it to drop icmp host unreachable responses. That way, the icmp response is dropped before it reaches my program and i get a "send succeeded" all the time, forever and ever, whether the host is up or down.
Back to
Seekers of Perl Wisdom
|
|