I've just stumbled upon Microsoft's HTTP Server API. The introduction states:
The HTTP Server API enables applications to communicate over HTTP without using Microsoft Internet Information Server (IIS). Applications can register to receive HTTP requests for particular URLs, receive HTTP requests, and send HTTP responses. The HTTP Server API includes SSL support so that applications can exchange data over secure HTTP connections without IIS. It is also designed to work with I/O completion ports.
Finding this cool, I took a long hard look at the list of functions for both versions of the API. Now, the only other part of the documentation that mentions I/O completion ports is the HttpReceiveHttpRequest
() function. The last parameter is an optional OVERLAPPED
structure with the following description:
For asynchronous calls, set
pOverlapped
to point to anOVERLAPPED
structure; for synchronous calls, set it toNULL
. A synchronous call blocks until a request has arrived in the specified queue and some or all of it has been retrieved, whereas an asynchronous call immediately returnsERROR_IO_PENDING
and the calling application then usesGetOverlappedResult()
or I/O completion ports to determine when the operation is completed. For more information about using OVERLAPPED structures for synchronization, see Synchronization and Overlapped Input and Output.
There is no other information, and all structures are opaque and deliberately hide connection information. Also notice that the Synchronization and Overlapped Input and Output subject makes no mention of the HTTP API.
Does anyone have any idea on how to connect the HTTP API's queue to an I/O completion port?
I/O completion ports provide an efficient threading model for processing multiple asynchronous I/O requests on a multiprocessor system. When a process creates an I/O completion port, the system creates an associated queue object for threads whose sole purpose is to service these requests.
A completion port thread will only be used briefly to mark the corresponding task in . NET as completed. If you start several FileStream instances in a loop, then the thread pool will create more IOCP threads to handle all the completing I/O request packets.
In this article, you will learn about worker thread and I/O Completion Port (IOCP). Every . NET/. NET Core application is associated with a thread pool and is a collection of threads that effectively executes asynchronous calls of an application. These threads on the thread pool are known as Worker threads.
Using IO completion ports is trivially simple in theory, but abomnible in practice :P
the "normal" usage is:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With