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

# io\_fd\_flags(3)

prepare descriptor for io\_wait

## NAME

io\_fd\_flags - prepare descriptor for io\_wait

## SYNTAX

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

int **io\_fd**(int64 fd);

\#ifdef HAVE\_IO\_FD\_FLAGS

int **io\_fd\_flags**(int64 fd);

## DESCRIPTION

io\_fd\_flags behaves just like io\_fd, but certain flags can be bitwise-ORed to it to alter its behavior:

- IO\_FD\_CANWRITE

  tell io\_fd that the descriptor is writable.  This is useful so io\_wantwrite can queue the descriptor immediately and there is no need to query the operating system event reporting mechanism.

- IO\_FD\_BLOCK

  tell io\_fd that the descriptor is blocking.

- IO\_FD\_NONBLOCK

  tell io\_fd that the descriptor is non-blocking.

Normally, io\_fd calls fcntl to ask the operating system whether the descriptor is blocking or not.  The frameworks needs to know because it alters how io\_tryread and io\_trywrite handle the socket.  Never pass both IO\_FD\_BLOCK and IO\_FD\_NONBLOCK at the same time.

Newly connected stream sockets are always writable if the connection is established, so it is usually safe to pass IO\_FD\_CANWRITE.  The main exception case where IO\_FD\_CANWRITE should not be passed is on a non-blocking socket where a connect() is pending.  Then you need to poll for writability to get notified when the connection is established.

## RETURN VALUE

io\_fd\_flags returns 1 on success, 0 on error.

## SEE ALSO

[io\_fd(3)](/io_fd/3.md), [io\_fd\_canwrite(3)](/io_fd_canwrite/3.md)
