How to check if there is any data in the file descriptor?

I would like to know if fd has data to read. I tried ioctl with FIONREAD , but this results in a "Operation without support" error. Any ideas?

+6
c posix
source share
2 answers

You can use select() with a null (not NULL ) timeout.

+6
source share

Use poll() or select() in the file descriptor.

+2
source share

All Articles