Consider converting this to use poll() instead of select(); poll() is just as portable (both are POSIX.1-2001) and doesn't have the "if your file descriptor is > 1024 you're dead" bug to which select() subjects us.