---
name: "tickit_watch_io"
section: "3"
platform: "linux"
package: "libtickit-dev"
version: "0.4.3-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/tickit_watch_io"
---

# tickit\_watch\_io(3)

invoke a callback when IO is possible

## NAME

tickit\_watch\_io - invoke a callback when IO is possible

## SYNOPSIS

```
#include <tickit.h>

typedef enum TickitIOCondition;

typedef struct {
  int fd;
  TickitIOCondition cond;
} TickitIOWatchInfo;

typedef int TickitCallbackFn(Tickit *t, TickitEventflags flags,
    void *info, void *user);

void *tickit_watch_io(Tickit *t, int fd, TickitIOCondition cond,
    TickitBindFlags flags, TickitCallbackFn *fn, void *user);
```

Link with *-ltickit*.

## DESCRIPTION

**tickit\_watch\_io**() registers a callback function to be invoked by the toplevel event loop when IO operations are possible on a given file descriptor. A registered callback will be invoked by a running call to [**tickit\_run**(3)](/tickit_run/3.md). The callback function will be invoked whenever the file descriptor is readable, writable, or in a hang-up condition, depending on the requested condition types. The *info* pointer will point to a structure containing the file descriptor and a bitmask of the IO operations currently possible.

The *cond* argument to **tickit\_watch\_io**() should be a bitmask of at least one of the following values:

- **TICKIT\_IO\_IN**

  The file descriptor is ready to perform an input operation, such as reading bytes.

- **TICKIT\_IO\_OUT**

  The file descriptor is ready to perform an output operation, such as writing bytes.

- **TICKIT\_IO\_HUP**

  The file descriptor is in a hang-up condition. Typically this means that a connection such as a socket or pipe has been closed by the peer.

When the callback function is invoked, the *info* struct will contain the file descriptor in the *fd* field, and the current IO conditions in the *cond* field. This may be one of the values given above, and in addition may also be one of the following:

- **TICKIT\_IO\_ERR**

  The file descriptor is in an error condition.

- **TICKIT\_IO\_INVAL**

  The file descriptor itself is invalid and does not represent an open file.

If registered with the **TICKIT\_BIND\_FIRST** flag, the callback will be inserted at the start of the queue, coming before others. If not, it is appended at the end.

If cancelled by [**tickit\_watch\_cancel**(3)](/tickit_watch_cancel/3.md) the callback function is invoked with just the **TICKIT\_EV\_UNBIND** flag if it had been registered with **TICKIT\_BIND\_UNBIND**.

## RETURN VALUE

**tickit\_watch\_io**() returns an opaque identifier pointer.

## SEE ALSO

[**tickit\_new\_stdio**(3)](/tickit_new_stdio/3.md), [**tickit\_watch\_timer\_after\_msec**(3)](/tickit_watch_timer_after_msec/3.md), [**tickit\_watch\_timer\_at\_epoch**(3)](/tickit_watch_timer_at_epoch/3.md), [**tickit\_watch\_later**(3)](/tickit_watch_later/3.md), [**tickit\_watch\_signal**(3)](/tickit_watch_signal/3.md), [**tickit\_watch\_process**(3)](/tickit_watch_process/3.md), [**tickit\_watch\_cancel**(3)](/tickit_watch_cancel/3.md), [**tickit**(7)](/tickit/7.md)
