Here's another useful class:
wiocp::IoCompPort. This template
wraps the I/O Completion port apis in a way that makes it very easy to create your own
IOCP-based server applications.
The class is defined like this:
class T, // derived class
class TOV, // overlapped class (you can use DefOverlapped)
class TCK // completion key class
> class IoCompPort
IoCompPort is very easy: Just derive your own class from
and implement a few functions.
What are the benefits:
IoCompPort wraps the ugly IOCP apis with type-safe template fuctions.
It also saves you from having to call the apis directly, since it handles the IOCP thread-pool for you,
taking care of thread creation/destruction, and just calling your implementation function to
process I/O requests. Another benefit is that it allows you to easily pass all the state information
you need on your io requests either through the OVERLAPPED struct or through the CompletionKey
(wiocp.h has all the information you need to use either or both!).
UPDATE 08/01/2001: Thanks to Andrew MacLean for pointing out to me that with a simple
fix, the ban on virtual functions in the OVERLAPPED-derived class could be lifted (and beating the
thing on my head several times until I fixed it
Here's the file: winterdom_cpp.zip