Network programming (ten)-udp basic programming

1. Buffer

udp does not have an actual buffer, so as long as the udp buffer size is greater than the low water mark of the send buffer, it can always be written. The successful return of udp call write indicates that the written datagram has been added to the output queue of the link layer. If the queue does not have enough space, the kernel usually returns an ENOBUFS error, or no error at all. When udp writes a data larger than the sending buffer size, it will return EMSGSIZE error.
udp has no actual sending buffer, but there is a receiving buffer.
udp has no flow control. When the sending end sends data faster than the receiving end, when the receiving end After the receiving buffer is full, the data sent later will be discarded.
If the host is multihomed (multiple network cards), then the temporary port of the udp client is selected by the kernel when the sendto is called for the first time, and cannot be changed. The ip address can be changed, for example, one message is sent from the ip1 network card, and another message is sent from the ip2 network card

2. Send

Insert picture description here

3.connect

Insert picture description here
Insert picture description here

4. Performance

Insert picture description here

Guess you like

Origin blog.csdn.net/chengcheng1024/article/details/115308498