How to set the don't fragment (DF) flag on a socket?
问题 I am trying to set the DF (don't fragment flag) for sending packets using UDP. Looking at the Richard Steven's book Volume 1 Unix Network Programming; The Sockets Networking API, I am unable to find how to set this. I suspect that I would do it with setsockopt() but can't find it in the table on page 193. Please suggest how this is done. 回答1: You do it with the setsockopt() call, by using the IP_DONTFRAG option:: int val = 1; setsockopt(sd, IPPROTO_IP, IP_DONTFRAG, &val, sizeof(val)); Here's