UDP response

UDP does not send any response, but will it send any response?

I installed the UDP server client program. If I let the client send data to a non-existent server, then will the client get any response?

My guess is:

Client → Broadcast Server Address (ARP) Server → Reply to Client with its MAC Address (ARP) Client sends data to the server (UDP)

In any case, the client will receive only an ARP response. If the server exists or not, it will not receive any UDP response?

The client uses the sendto function to send data. We can get error information after calling sendto.

So my question is how is this information available when the client does not receive an answer. The error code can be obtained from WSAGetLastError.

I tried to send data to a non-existent host, but sendto call succeeded. According to the documentation, it should fail with a return value of SOCKET_ERROR.

Any thoughts ??

+5
source share
6 answers

You will never receive an error message or notification for a UDP packet that has not reached the target.

+6
source

Failed to make sendto call. The datagram was sent to the destination.

The receiver of the datagram or any router on the way to it may return an error response (invalid host, unreachable port, TTL exceeded). But the sendto call will be history at the time your system sendto it. Some operating systems provide a way to find out, often with getsockopt . But since you cannot expect to receive an error response, since it depends on network conditions that you do not control, it is usually best to ignore it.

Reasonable protocols on top of UDP usage responses. If you did not receive an answer, either the other end did not receive your datagram, or the answer did not return you.

+5
source

"UDP is a simpler, message-based connection protocol. No connection effort is made to set up a special end-to-end connection. Communication is achieved by transferring information in one direction >, from source to destination, without checking if the destination is there, or if it is ready to receive information.

+3
source

The machine to which you send packets may respond with an ICMP UDP port message that is not available.

+3
source

UDP is implemented over IP. You send UDP packets to hosts identified by IP addresses, not MAC addresses.

And as indicated, UDP itself will not send a response, you will have to add code to do it yourself. Then you will need to add code to wait for a response, and take the right action if the response is lost (usually re-sent by timer until you decide that the other end is "dead"), etc.

+2
source

If you need reliable UDP, like when ordering or checking, so TCP / IP will give you a look at RUDP or reliable UDP. Sometimes you need validation, but a mixture of UDP and TCP can be raised to TCP reliability, which is a bottleneck.

For most large-scale MMOs for isntance, UDP and Reliablity UDP are a means of communication and reliability. All RUDP is to add a smaller part of TCP / IP to check and order specific messages, but not for everyone.

The common network library for game development is Raknet, which has a built-in interface.

RUDP http://www.javvin.com/protocolRUDP.html

RUDP example using Raknet and Python http://pyraknet.slowchop.com/

+1
source

All Articles