pkahn
August 13th, 2009, 08:17 PM
Hi,
I have a rather general question about sockets with respect to sendto().
I have noticed on greater that one platform that sendto() does not return an error message when the host address for a local subnet does not exist.
Assume for example, an adapter address of 10.0.0.1 and a subnet mask of 255.255.255.0. If I use sendto() to transmit a UPD packet to 10.0.0.15 and there is no host with that address on the local subnet, I would expect for sendto() to return an error.
I understand, at the UDP level, no response is expected as there is no connection and there is no reply. However, if the stack or any other host on the local subnet has never communicated with the desired host (10.0.0.15), the stack will first send out an ARP request to resolve 10.0.0.15 to an Ethernet address. Since there is no reply to the ARP request, the stack is unable to resolve the IP address to an Ethernet address. At that point, I would assume it would return an error to the original socket call indicating that the host is unavailable or unknown. But in all cases and on multiple operating systems, the call succeeds, reporting the correct number of bytes sent. However, a packet sniffer shows only the ARP request was sent.
Can anyone explain why this is?
Thanks much!
I have a rather general question about sockets with respect to sendto().
I have noticed on greater that one platform that sendto() does not return an error message when the host address for a local subnet does not exist.
Assume for example, an adapter address of 10.0.0.1 and a subnet mask of 255.255.255.0. If I use sendto() to transmit a UPD packet to 10.0.0.15 and there is no host with that address on the local subnet, I would expect for sendto() to return an error.
I understand, at the UDP level, no response is expected as there is no connection and there is no reply. However, if the stack or any other host on the local subnet has never communicated with the desired host (10.0.0.15), the stack will first send out an ARP request to resolve 10.0.0.15 to an Ethernet address. Since there is no reply to the ARP request, the stack is unable to resolve the IP address to an Ethernet address. At that point, I would assume it would return an error to the original socket call indicating that the host is unavailable or unknown. But in all cases and on multiple operating systems, the call succeeds, reporting the correct number of bytes sent. However, a packet sniffer shows only the ARP request was sent.
Can anyone explain why this is?
Thanks much!