Use getsockopt (). This site has a good breakdown of usage and parameters that you can get.
On Windows, you can:
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 detection (it will check what maximum UDP packet size is between this destination and destination, and select this), or if MTU detection is turned off, set the maximum MTU interface size and larger fragment. If you are sending over Ethernet, a typical MTU is 1,500 bytes.
Steve m
source share