IOHandler(3I)
π IOHandler(3I) π
okay bestie, welcome to the InterViews Reference Manual β¨ today we're talking about IOHandler β the girl who reads input, writes output, or handles an I/O exception or a timeout. she's doing it ALL and she's doing it flawlessly π
πΈ SYNOPSIS πΈ
#include <Dispatch/iohandler.h>
β¨ DESCRIPTION β¨
so like. an iohandler has four whole jobs and she does not complain once:
- she reads data from a file descriptor π₯
- she writes data to a file descriptor π€
- she handles an I/O exception on a file descriptor π
- she handles a timer's expiration β°
and here's the slay part: once you have asked the dispatcher to attach an iohandler to a file descriptor or a timer, the dispatcher will automatically notify the iohandler the moment the file descriptor's I/O condition changes or the timer expires. you don't have to do anything. she just shows up. main character energy fr fr π
also, for convenience, you can use a derived generic class (go look at IOCallback(3I), she's in SEE ALSO) to make the iohandler do nothing more than call an arbitrary object's member function. lazy girlboss move, we respect it π«Ά
π PUBLIC OPERATIONS π
virtual int inputReady(int fd)
virtual int outputReady(int fd)
virtual int exceptionRaised(int fd)
okay so these three are a little squad. the dispatcher will call one of these functions to let an iohandler know that:
- it can read data from a file descriptor,
- it can write data to a file descriptor, or
- it needs to handle an I/O exception on a file descriptor.
the iohandler should do the appropriate thing and then tell the dispatcher what to do next. and the return value is THE WHOLE VIBE CHECK, so listen up:
- a negative return value π β means the iohandler hit an error, or she simply doesn't want to read or write anything more. the dispatcher will unlink the iohandler from its file descriptor automatically. she's out, no follow-up needed.
- a positive return value π₯ β means the iohandler didn't read or write everything that it could have. the dispatcher will call the iohandler again in round robin fashion WITHOUT checking select, which means the iohandler gets called again as soon as the rest of the iohandlers have performed their actions. she's getting her turn again, immediately, no waiting.
- a zero return value β¨ β means the iohandler finished reading or writing everything it was able to. the dispatcher must check the descriptor's status with the select call before it can call the iohandler again. patient. methodical. we love her.
no cap, that middle one is the sneaky one β positive means you're coming back around WITHOUT a select check, so don't be weird about it π
virtual void timerExpired(long sec, long usec)
the dispatcher will call this function to let an iohandler know a timer has expired β°π
for informational purposes (iykyk), the parameters give the current time in seconds and microseconds since midnight January 1, 1970. yes bestie, epoch time. she's timeless, literally.
and if the iohandler wants to reset the timer, she has to tell the dispatcher to start another timer. it will not just happen on its own. periodt. π
π¦ SEE ALSO π¦
Dispatcher(3I)IOCallback(3I)
and that's the whole page, bestie π₯° this one came out of InterViews, dated 9 January 1991, and she's still iconic to this day. go forth and handle your I/O ππ
π¦ where this page comes from
- debian bookworm: ivtools-dev 2.0.11d.a1-1+b4
- debian trixie: ivtools-dev 2.0.11d.a1-3+b4
- ubuntu jammy: ivtools-dev 2.0.11d.a1-1build1
- ubuntu noble: ivtools-dev 2.0.11d.a1-3build1
- ubuntu questing: ivtools-dev 2.0.11d.a1-3build7
- ubuntu resolute: ivtools-dev 2.0.11d.a1-3build9
- ubuntu stonking: ivtools-dev 2.1.1+git.2025.07.26.a1-1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms