# SO_SNDTIMEO option on UDP socket?



## rambetter (Nov 8, 2010)

So, SO_SNDTIMEO makes sense on a TCP socket.  If you cannot write some data to the TCP socket in some number of microseconds, raise an error condition.

However, I'm using UDP sockets.  The SO_RCVTIMEO is very important to me, and it makes sense - I expect to receive a packet from somewhere, and I only want to block for a certain length of time.  However, does SO_SNDTIMEO make sense on a UDP socket?  I'm able to set it, but does it change the characteristics of the UDP socket in any way?  The reason I ask this is because it seems that with UDP, packets are sent immediately and if there is any kind of traffic congestion, then tough luck.  So, I'm just wondering if I should be setting SO_SNDTIMEO on my UDP socket in my code, or just leave it alone.  I would expect a socket write (e.g. sendto() on a UDP socket) to return immediately in all cases.  Am I correct?


----------



## expl (Nov 8, 2010)

sendto() on a UDP socket will block only til your data is copied to internal buffer then it will return. It will not even wait til its send to your hardware.


----------



## rambetter (Nov 8, 2010)

That's what I thought, thanks.  I couldn't find the answer after some simple searches.


----------

