_dbus_write/read/poll etc and regular files

Tor Lillqvist tml@iki.fi
Mon Jan 17 13:45:55 PST 2005


Rob Taylor writes:
 > Out of interest, in what problematic way is WaitForMultipleObjects not
 > select-like?

One cannot use WaitForMultipleObjects to "select" on file handles. (I
don't mean the C library file descriptors (which the Win32 kernel of
course can't know anything about), but the underlying kernel objects).

It's possible to open a file for "overlapped IO". Then you must use
only asynchronous overlapped IO to/from it. Each ReadFile or WriteFile
call passes an OVERLAPPED struct, which contains an optional HEVENT
(Event handle), and this Event is signalled when the IO
*completes*. I.e. not when IO *is possible* (which would be more like
select()). So it is quite different from select(). With select() you
wait until I/O is possible, and then do it. With overlapped I/O you
start the I/O asynchronously, and do something else or wait until it
is done.

To use overlapped IO, you must know from the beginning when opening
the file that you will use it, and you cannot use non-overlapped
IO. And vice versa.

--tml




More information about the dbus mailing list