roxen.lists.pike.general

Subject Author Date
Blocking vs callback mode (Was: pike@roxen.com) Martin Stjernholm <mast[at]lysator[dot]liu[dot]se> 21-01-2009
Marc Dirix <<marc[at]electronics-design.nl>> wrote:

> For some reason the call to fd->set_blocking_keep_callbacks() does
> not work. As data arives on the socket the callback is still called.

Which shows that it works, actually. ;) You confuse blocking mode with
callback mode. The two are in fact unrelated:

Blocking mode means that you can call read() and write() without
risking that they block.

Callback mode means that your read callback gets called when there's
data to read (well, read() has already been called for you, but
nevertheless), and that your write callback gets called when there's
space in the send buffer.

Then it's another thing that nonblocking mode often is used with
callback mode, and vice versa. These concepts have traditionally been
mixed up even in the docs, so you're not alone. But I've tried to
improve the docs in Stdio.File since around 7.6 iirc.

You're in callback mode whenever you have callbacks installed (and of
course you can be in callback mode only on, say, the reading side by
having a read callback installed but not a write callback). There's
currently no way to disable callback mode and keeping the callback
installed.