Why should I use, or not use, MSG_CONFIRM?

前端 未结 2 1713

I am acquainting with BSD sockets, and flicking through the man page of sendto, I bumped into MSG_CONFIRM flag, which is quite mysterious to me at

相关标签:
2条回答
  • 2020-12-19 06:29

    You should only set the flag if the datagram you're sending is a direct response to a datagram you just received from the same peer.

    If you're sending an initial request, or sending a datagram in response to some other event (like user input, or a timeout) then you should not set the MSG_CONFIRM flag.

    0 讨论(0)
  • 2020-12-19 06:37

    The reason to not send it is in case the mac address for the IP changes over time. If you're constantly telling your system not to check, it will continue to send to the same MAC even if the IP address isn't there anymore.

    It seems the case for sending it requires a very special situation where you can guarantee things about the recipient of your messages. The overhead of a periodic ARP request is very low, so the benefits are extremely limited.

    0 讨论(0)
提交回复
热议问题