I have an UDP server and I need to close connection to a client after 10 seconds . How can I implement that ? ... C under linux
Printable View
I have an UDP server and I need to close connection to a client after 10 seconds . How can I implement that ? ... C under linux
You can use a timer:
SourceForge.net: POSIX timers - cpwiki
and then sleep() before you close() the socket descriptor in your UDP server.
You could also set a timeout on the socket, depending on what you're doing with the socket though.
But waiting 10 seconds and doing nothing, then closing the socket doesn't make much sense.
Hey excellent point.