Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UDP sendto() and recvfrom() max buffer size

Tags:

c++

c

I understand that the default max buffer size I can use with these functions is 65507 (5535 - IPv4 header - UDP header). However, is there a way to change this? I need to be able send a larger buffer ~66000 bytes. I tried using the setsockopt() function, but it didn't seem to work.

Thanks!

like image 269
Albert Myers Avatar asked Jul 20 '10 16:07

Albert Myers


1 Answers

No.

UDP only provides a datagram as the data part of an IP packet, an IP packet has a 16 bit length field thus limiting the data to 2^16 bytes including the headers, or 65507 bytes for the UDP data part(assuming no ipv4 options), there's no way to handle larger packets with UDP besides splitting them up in several packets and handle the reassembly etc. yourself.

like image 77
nos Avatar answered Sep 21 '22 20:09

nos