TICKIT_WATCH_IO(3)

πŸ“¦
version 0.4.5 Β· 3 versions
, in debian bookworm, debian trixie, fedora 43, fedora 44, nixos 26.05, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– TICKIT_WATCH_IO(3) πŸ’–

okay bestie, gather round, because this is tickit_watch_io from the Library Functions Manual and she is so useful. buckle up πŸŽ€


✨ NAME ✨

tickit_watch_io β€” invoke a callback when IO is possible

like literally, it's the "hey bestie, wake me up when there's something to read/write" function πŸ’…


🌸 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 πŸ¦‹

so tickit_watch_io() signs your callback function up to be invoked by the toplevel event loop whenever IO operations become possible on a given file descriptor. a registered callback gets invoked by a running call to tickit_run(3). it'll get called whenever the file descriptor is readable, writable, or in a hang-up condition β€” whichever condition types you asked for, no more no less. the info pointer points at a structure holding the file descriptor plus a bitmask of the IO operations that are currently possible. πŸ‘‘

the cond argument you hand to tickit_watch_io() should be a bitmask of at least one of these values:

  • TICKIT_IO_IN β€” the file descriptor is ready to do an input operation, like reading bytes πŸ“–
  • TICKIT_IO_OUT β€” the file descriptor is ready to do an output operation, like writing bytes ✍️
  • TICKIT_IO_HUP β€” the file descriptor is in a hang-up condition. typically this means a connection like a socket or a pipe has been closed by the peer. not me getting ghosted by a socket πŸ’€

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. that may be one of the values above, and in addition it may also be one of these:

  • 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 you registered with the TICKIT_BIND_FIRST flag, the callback gets inserted at the start of the queue, coming before the others. if not, it's appended at the end. front of the line energy vs. joining the back of the queue, choose your vibe ✨

if it gets cancelled by tickit_watch_cancel(3), the callback function is invoked with just the TICKIT_EV_UNBIND flag, but only if it had been registered with TICKIT_BIND_UNBIND. periodt.


πŸ‘‘ RETURN VALUE πŸ‘‘

tickit_watch_io() returns an opaque identifier pointer. that's your little ticket, your receipt, your proof of registration 🫢


🌈 SEE ALSO 🌈


and that's the whole page, bestie β€” this one's from the TICKIT_WATCH_IO(3) era of the Library Functions Manual, and yeah, the footer is literally just the same TICKIT_WATCH_IO(3) all over again, iconic of her honestly. stay readable, stay writable, and never hang up unless the peer does it first πŸ’œβœ¨