Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximum buffer length for sendto?

How do you get the maximum number of bytes that can be passed to a sendto(..) call for a socket opened as a UDP port?

like image 233
epatel Avatar asked Aug 25 '08 10:08

epatel


People also ask

What is the maximum buffer size?

The maximum size, in bytes, of a buffer that stores messages while they are processed for an endpoint configured with this binding. The default value is 65,536 bytes.

What is Max buffer size of TCP socket?

The default buffer size is 8 KB. The maximum size is 8 MB (8096 KB). The optimal buffer size depends on several network environment factors including types of switches and systems, acknowledgment timing, error rates and network topology, memory size, and data transfer size.

What is buffer size in UDP?

The default send buffer size for UDP sockets is 65535 bytes. The default receive buffer size for UDP sockets is 2147483647 bytes.

What is Sendto?

The Send to feature, introduced with Windows 95, is an option in the Windows context menu when you right-click a file or folder. It "sends" a file to a program of your choice, opening the file with the program.


1 Answers

Use getsockopt(). This site has a good breakdown of the usage and options you can retrieve.

In Windows, you can do:

int optlen = sizeof(int);
int optval;
getsockopt(socket, SOL_SOCKET, SO_MAX_MSG_SIZE, (int *)&optval, &optlen);

For Linux, according to the UDP man page, the kernel will use MTU discovery (it will check what the maximum UDP packet size is between here and the destination, and pick that), or if MTU discovery is off, it'll set the maximum size to the interface MTU and fragment anything larger. If you're sending over Ethernet, the typical MTU is 1500 bytes.

like image 187
Steve M Avatar answered Sep 28 '22 06:09

Steve M