0

As I understand, UDP is a unreliable protocol. In one of the project I'm working one, local UDP socket is suggested as mean of IPC between two process. Is local UDP entirely reliable? I'd imagine it is but just want to confirm.

If it is, what's the difference between local UDP and domain socket?

Thanks,

lang2
  • 11,433
  • 18
  • 83
  • 133
  • 1
    http://stackoverflow.com/questions/2128701/is-sending-data-via-udp-sockets-on-the-same-machine-reliable – cnicutar Apr 26 '12 at 07:13
  • UDP is better suited for realtime application across a network where "newness" matters more then completeness. It's distinct from TCP, which repeats itself indefinitely until all messages are received. Other answers suggest implementation servers / clients in UDP could be unreliable. That could be true of any protocol. The 'unreliability' aspect is best considered in light of retransmission. https://stackoverflow.com/questions/12956685/what-are-the-retransmission-rules-for-tcp and for UDP reliable is possible https://stackoverflow.com/a/5485831/775686 – gtzilla Oct 03 '18 at 00:03

2 Answers2

3

UDP is not reliable under any circumstances. For example, if the receiver is not reading messages as quickly as they are arriving, then its receive buffer will overflow and all additional messages will be dropped.

The difference between UDP and a domain socket is that a domain socket is effectively just two sockets talking to another, while UDP sticks two instances of the IP stack in between two sockets. Here is a pretty good description:

unix domain sockets vs. internet sockets

Seth Noble
  • 3,233
  • 19
  • 31
0

There is no guarantee. It is UDP after all. Someone's implementation could just disregard every second packet you sent, local or remote, and still be a valid implementation.

In reality there are several levels of OS interaction between you and the other process, any of which could fail for any reason.

Named pipes or similar might be a better option. Or, if you require a reliable socket, TCP.

Will
  • 4,585
  • 1
  • 26
  • 48