Unix Programming - Expected an error from sendto()

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > November 2006 > Expected an error from sendto()





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Expected an error from sendto()
Spoon

2006-11-24, 1:22 pm

Hello,

I wrote a small app that sends datagrams to a box on the LAN.

If that box is turned off, the ARP requests sent by my OS will time out.

When I call sendto() 1000 times per second, it never returns an error.

It seems to me it would make sense for the OS to return an error
when several ARP requests have timed out. Is that crazy?

Regards.
Maxim Yegorushkin

2006-11-24, 1:22 pm


Spoon wrote:

> I wrote a small app that sends datagrams to a box on the LAN.
>
> If that box is turned off, the ARP requests sent by my OS will time out.
>
> When I call sendto() 1000 times per second, it never returns an error.
>
> It seems to me it would make sense for the OS to return an error
> when several ARP requests have timed out. Is that crazy?


Your OS may require you to connect() udp socket first.

man udp(7)
All fatal errors will be passed to the user as an error
return even
when the socket is not connected. This includes asynchronous
errors
received from the network. You may get an error for an earlier
packet
that was sent on the same socket. This behaviour differs
from many
other BSD socket implementations which don't pass any errors
unless the
socket is connected. Linux's behaviour is mandated by RFC 1122.

Rainer Weikusat

2006-11-26, 1:16 pm

"Maxim Yegorushkin" <maxim.yegorushkin@gmail.com> writes:
> Spoon wrote:
>
> Your OS may require you to connect() udp socket first.
>
> man udp(7)
> All fatal errors will be passed to the user as an error
> return even
> when the socket is not connected. This includes asynchronous
> errors
> received from the network.


'Asychronous errors from the network' refers to ICMP unreachbility
messages. 'send' or 'sendto' does not define a suitable error code
for this case and why should it? UDP is an unreliable protocol which
does 'best effort' delivery. If somebody wants to have reliable
communication using UDP, a suitable, application-specific
retransmission and acknowledgment scheme needs to be
implemented[*]. Such a scheme would detect the situation from the
original post due to lack of acknowledgment.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com