What's time set to? It could be timing out?
If you're using Linux then time is modified after every call to select() so you must reinitialise it with whatever timeout you wanted. Not everybody does this so your code might only set timeout once.