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

# io\_canwrite(3)

return a file descriptor that can be written to

## NAME

io\_canwrite - return a file descriptor that can be written to

## SYNTAX

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

int64 **io\_canwrite**();

## DESCRIPTION

io\_canwrite returns the next file descriptor that can be written to. You have to have used io\_wantwrite() 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 writable by the operating system.

Please note that there is no guarantee that you can still write data without blocking to that descriptor, just that you could when io\_wait() or io\_waituntil() were called.  Another process could have written something before you.  Look at the result from io\_trywrite().

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 only use [io\_trywrite(3)](/io_trywrite/3.md), [io\_sendfile(3)](/io_sendfile/3.md) or [iob\_send(3)](/iob_send/3.md) to write to the file, not plain [write(2)](/write/2.md).  If you use [write(2)](/write/2.md) and 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)
