I have a question about socket programming. When I use socket to send the data, we can use the API such as sendto() to send using TCP or UDP. For sendto(), we give a array pointer and the byte number we want to send.
In this case, if I gave a large byte number (e.g.: 20000 bytes), based on my understanding, MTU of the network will not be that big so socket actually send mutiple packets instead of one big packet. Since these 20000 bytes are split into several UDP/TCP packets, but will these 20000 bytes be seen as one packet at beginning? Is this process UDP/TCP fragmentation ?
My another question is if I put the data size smaller than MTU into sendto(), then I can gurantee call sendto() once, socket only sends one TCP/UDP packet?
Thanks in advance.
send()
/sendto()
will tell you exactly how many bytes were actually accepted for transmission, you have to pay attention to it. – Remy Lebeau