Using HttpApi with I/O Completion Ports

Using IO completion ports is trivially simple in theory, but abomnible in practice :P

the "normal" usage is:

  1. Call CreateIOCompletionPort to create a IO completion port handle.
  2. Create a bunch of threads, and get each thread to loop, on a call to GetOverlappedResult. GetOverlappedResult will return when an overlapped operation associated with the port completes, with structures indicating which handle, and operation, was completed.
  3. As your program runs, and creates objects that it wishes to handle asynchronously, it associates each HANDLE with the IO CompletionPort handle by calling CreateIOCompletionPort again.

Now, each time the application issues an asynchronous operation on the HANDLE (which is signalled by passing in an OVERLAPPED struct) the notification of the completed operation will be indicated by one of the threads thats waiting on GetOverlappedResult returning.

The clear implication is that the HANDLE returned by HttpCreateRequestQueue can be associated with an IO Completion port and subsequent asynchronous operations will result in GetOverlappedResult's returning the result of the operation.