Any suggestions, how we can keep the socket alive over longer period of time?
and
Is there a way to set UDP timeout setting ...?
UDP is connectionless. If an application binds to a UDP server-socket and listens, it can wait for messages to arrive indefinitely.
The flipside is that there is no way to detect a lost UDP message at the protocol / socket level. If one machine sends a UDP message to another one, the first machine has no direct way of knowing if the message has arrived or not? There are no transport level timeouts to tell the sender to retransmit.
If you need reliability, timeouts, automatic retransmission, etc, you are better of using a connection-based transport protocol such as TCP.