protocol | TCP | UDP |
---|---|---|
Connectivity | Connection oriented | Connection less |
Duplex | Full duplex (1:1) | n:m |
reliability | Reliable (retransmission mechanism) | Unreliable (data loss after packet loss) |
Orderliness | Ordered (sort by SYN) | Disorder |
Boundedness | No, there is a sticky package | There are message boundaries, no sticky packets |
Congestion control | Have | no |
transfer speed | slow | fast |
Magnitude | low | high |
Head size | 20~60 bytes | 8 bytes |
UDP socket supports the connection status of n to m. It is written in the official document that the option in dgram.createSocket(options[, callback]) can specify reuseAddr, which is the SO_REUSEADDR flag. Through SO_REUSEADDR, n to m multicast can be realized simply Features (but only on systems that support multicast).