What is the difference between TCP_NODELAY and MSG_DONWAIT?I understand that one is specific to TCP and another is for generic socket option while sending, but does these two option behave differently in different scenarios?
Just like TCP_NODELAY, is MSG_DONTWAIT also disables Nagle algorithm ?
To be specific, I am trying to send data over my local LAN network and I don’t want my socket to be stuck because of any reason while sending,I just wish that it sends the packet and return immediately. which one is a better and more reliable option to do this.
(this question is specific to Linux sockets)
TCP_NODELAYwon’t help you here – the Nagle algorithm is just about how data is buffered in the TCP stack before it goes out, and won’t affect control flow in your program. What you want is a non-blocking socket – send calls will return immediately and you can query them later to find out whether anything happened or not.