in reply to Non-blocking read

If you're on a Unix like system you can user termios to set a timeout. Will a timeout do what you want?