In my recent project, I need to use the UDP protocol to transmit data.
If I send data by using size = s.sendto(data, (<addr>, <port>))
, will the UDP protocol ensure that the data is packed into one UDP packet?
If so, will size == len(data)
always be True
?
Is there anything that I misunderstood?
More precisely, will 'sendto()' split my data into several smaller chunks and then pack each chunk into UDP packet to transimit?
Finally, I got the answer from "UNIX Network Programming", Chapter 2.11 Buffer Sizes and Limitations, Section UDP Output.
This time, we show the socket send buffer as a dashed box because it doesn't really exist. A UDP socket has a send buffer size (which we can change with the SO_SNDBUF socket option, Section 7.5), but this is simply an upper limit on the maximum-sized UDP datagram that can be written to the socket. If an application writes a datagram larger than the socket send buffer size, EMSGSIZE is returned.