If you are in non-blocking mode you'll have to poll the device (or use select()) to see when data is there (and that would be in a loop).