---
name: "io_canread"
section: "3"
platform: "linux"
package: "libowfat-dev"
version: "0.32-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/io_canread"
---

# io\_canread(3)

return a file descriptor that can be read from

## NAME

io\_canread - return a file descriptor that can be read from

## SYNTAX

**#include \<libowfat/io.h\>**

int64 **io\_canread**();

## DESCRIPTION

io\_canread returns the next file descriptor that can be read from. You have to have used io\_wantread() on the file descriptor earlier, and you have to have called io\_wait() or io\_waituntil().

These functions then keep an internal data structure on which descriptors were reported readable by the operating system.

Please note that there is no guarantee that there still is data that can be read from the descriptor, just that there was data when io\_wait() or io\_waituntil() were called.  Another process could have read the data before you.  Look at the result from io\_tryread().

If there are no more descriptors that you can write to without blocking, io\_canwrite will return -1.  In this case you should call io\_wait() or io\_waituntil() again.

You should use [io\_tryread(3)](/io_tryread/3.md) to read from the descriptor, not plain [read(2)](/read/2.md).  If you use [read(2)](/read/2.md) and you get EAGAIN, call [io\_eagain(3)](/io_eagain/3.md).

## SEE ALSO

[io\_wait(3)](/io_wait/3.md), [io\_canwrite(3)](/io_canwrite/3.md), [io\_eagain(3)](/io_eagain/3.md)
