wait X seconds implementation - C under linux

I have an UDP server and I need to close connection to a client after 10 seconds . How can I implement that ?
closed account (S6k9GNh0)
Use a timer and wait for ten seconds?
There's this function called "sleep." Maybe you can find a man-page or something for it, because it'll be really hard to figure out how to use it and what it does, otherwise. They should start naming their functions better; they aren't descriptive enough.

Edit: Here's a man page: http://linux.die.net/man/3/sleep
Last edited on
Sleep functions block execution of your program.
When handling sockets, you want to use a non-blocking function instead. On POSIX systems, choose one of select() or poll().
http://linux.die.net/man/2/select
http://linux.die.net/man/2/poll
Or hand off the socket to a thread that sleep()s for 10 seconds then closes the connection.
Topic archived. No new replies allowed.