Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UDP Response

UDP doesnot sends any ack back, but will it send any response?

I have set up client server UDP program. If I give client to send data to non existent server then will client receive any response?

My assumption is as;

Client -->Broadcast server address (ARP) Server --> Reply to client with its mac address(ARP) Client sends data to server (UDP)

In any case Client will only receive ARP response. If server exists or not it will not get any UDP response?

Client is using sendto function to send data. We can get error information after sendto call.

So my question is how this info is available when client doesn't get any response. Error code can be get from WSAGetLastError.

I tried to send data to non existent host and sendto call succeeded . As per documentation it should fail with return value SOCKET_ERROR.

Any thoughts??

like image 365
anand Avatar asked Dec 02 '08 11:12

anand


People also ask

What is UDP response?

User Datagram Protocol (UDP) is a communications protocol that is primarily used to establish low-latency and loss-tolerating connections between applications on the internet.

Does UDP send a response?

Now, since UDP is a connection-less protocol so unlike TCP, UDP server will not send response over some connection, instead, UDP server will extract the source IP address and source port from the request and send the response back to client.

What is UDP and how it works?

The User Datagram Protocol (UDP) is a lightweight data transport protocol that works on top of IP. UDP provides a mechanism to detect corrupt data in packets, but it does not attempt to solve other problems that arise with packets, such as lost or out of order packets.

What does UDP stand for?

User Datagram Protocol (UDP) refers to a protocol used for communication throughout the internet.


2 Answers

You can never receive an error, or notice for a UDP packet that did not reach destination.

like image 149
M. Utku ALTINKAYA Avatar answered Sep 25 '22 19:09

M. Utku ALTINKAYA


The sendto call didn't fail. The datagram was sent to the destination.

The recipient of the datagram or some router on the way to it might return an error response (host unreachable, port unreachable, TTL exceeded). But the sendto call will be history by the time your system receives it. Some operating systems do provide a way to find out this occurred, often with a getsockopt call. But since you can't rely on getting an error reply anyway since it depends on network conditions you have no control over, it's generally best to ignore it.

Sensible protocols layered on top of UDP use replies. If you don't get a reply, then either the other end didn't get your datagram or the reply didn't make it back to you.

like image 36
David Schwartz Avatar answered Sep 23 '22 19:09

David Schwartz