
Carlo Wood wrote:
On Mon, Sep 13, 2004 at 10:18:00AM -0500, Aaron W. LaFramboise wrote:
But while that might be possible on GNU/Linux, it might be impossible on windows (for example). The demand to provide a portable interface forces us to create (hidden) threads therefore. If a user decided that he only needs one thread and the library is not allowed to implement the requested interface by running two or more threads internally, then how can I implement an interface that allows one to wait for events on 100 sockets, a timer, a few named pipes, a fifo and some large diskfile I/O at the same time? That is possible on linux, but I failed to figure out how this can be done on windows :/
I am confused. What feature is missing on Windows? It is my perception that the Windows API is quite as expressive as anything Linux has.
No, I am confused. You do as if it trivial. But where is the answer to my question? How can I implement an interface that allows one to wait for events on 100 sockets, a timer, a few named pipes, a fifo and some large diskfile I/O at the same time?
Sorry, I thought it was rhetorical. -100 sockets: implemented using I/O completion so they trigger with APC's: no slots used on NT or 9x with winsock 2.0 (but probably requires a separate thread on win9x with winsock 1.1 or earlier due to going over the limit (can winsock 1.1 on win9x even handle 100 sockets?) ) -a timer: implemented internals, no handle slots needed. -a few named pipes: implemented with APC on NT, but 9x doesn't have named pipes at all. -a fifo: I'm assuming you mean a normal pipe. as above, APC on winNT, uses one handle slot on win9x. -some large diskfile io: uses APCs, or on Win9x, one handle slot. Total handles used: None on NT, two on win9x. That leaves 62 handles left. The key here is MsgWaitForMultipleObjectsEx(). (Both Msg- and -Ex are necessary.) Win95 mysteriously lacks this, so probably MsgWaitForMultipleObjects() should be used.
Is your answer WaitForMultipleObjects ? Then 1) what about the limit of 64? And 2) How can I use that to wait for events on SOCKET's? The only thing I can find for that is WSAWaitForMultipleEvents. But obviously you can call WSAWaitForMultipleEvents *and* WaitForMultipleObjects at the same time (without using threads).
1) I do not see how a realitistic use case would ever hit the limit. 2) IO completion routines. Aaron W. LaFramboise