views:

812

answers:

5

Hi

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??

+3  A: 

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

M. Utku ALTINKAYA
+2  A: 

The UDP protocol is implemented on top of IP. You send UDP packets to hosts identified by IP addresses, not MAC addresses.

And as pointed out, UDP itself will not send a reply, you will have to add code to do that yourself. Then you will have to add code to expect the reply, and take the proper action if the response is lost (typically resend on a timer, until you decide the other end is "dead"), and so on.

unwind
+1  A: 

"UDP is a simpler message-based connectionless protocol. In connectionless protocols, there is no effort made to set up a dedicated end-to-end connection. Communication is achieved by transmitting information in one direction, from source to destination without checking to see if the destination is still there, or if it is prepared to receive the information."

adam
A: 

If you need reliable UDP as in ordering or verification such that TCP/IP will give you take a look at RUDP or Reliable UDP. Sometimes you do need verification but a mixture of UDP and TCP can be held up on the TCP reliability causing a bottleneck.

For most large scale MMO's for isntance UDP and Reliablity UDP are the means of communication and reliability. All RUDP does is add a smaller portion of TCP/IP to validate and order certain messages but not all.

A common game development networking library is Raknet which has this built in.

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

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

Ryan Christensen
A: 

The machine to which you're sending packets may reply with an ICMP UDP port unreachable message.

JF