<p>What is Windows' best I/O event notification facility? </p>

<p>By best I mean something that ...</p>

<ol>
<li>doesn't have a limit on number of input file descriptors</li>
<li>works on all file descriptors (disk files, sockets, ...)</li>
<li>provides various notification modes (edge triggered, limit triggered)</li>
</ol>

[{'answer_id': 67546, 'author': 'Heron', 'author_id': 9837, 'author_profile': 'https://Stackoverflow.com/users/9837', 'pm_score': 2, 'selected': False, 'text': '<p>There isn\'t one yet, as far as I am aware.  A friend and I are working on an open source Windows epoll implementation (link below) but we\'re running into issues figuring out how to make it act the same as the Linux implementation.</p>\n\n<p>Current obstacles:</p>\n\n<ul>\n<li>In Linux, file descriptors and socket descriptors are interchangeable, but in Windows they are not.  Both must be compatible with an epoll implementation.</li>\n<li>In Windows it\'s quite tricky to get kernel events...  which is how epoll works in Linux.  We\'re guessing that a program using our cross-platform epoll library will run noticeably slower in Windows than Linux.</li>\n</ul>\n\n<p>I\'ll try to come back and update this post as we make progress with the project.</p>\n\n<p><a href="http://sourceforge.net/projects/cpoll" rel="nofollow noreferrer">http://sourceforge.net/projects/cpoll</a></p>\n'}, {'answer_id': 67594, 'author': 'Chris Smith', 'author_id': 9073, 'author_profile': 'https://Stackoverflow.com/users/9073', 'pm_score': 7, 'selected': True, 'text': '<p>In Windows, async operations are done by file operation, not by descriptor. There are several ways to wait on file operations to complete asynchronously.</p>\n\n<p>For example, if you want to know when data is available on a network socket, issue an async read request on the socket and when it completes, the data was available and was retrieved.</p>\n\n<p>In Win32, async operations use the <a href="http://msdn.microsoft.com/en-us/library/ms684342(VS.85).aspx" rel="noreferrer"><code>OVERLAPPED</code></a> structure to contain state about an outstanding IO operation.</p>\n\n<ol>\n<li>Associate the files with an <a href="http://msdn.microsoft.com/en-us/library/aa365198(VS.85).aspx" rel="noreferrer">IO Completion Port</a> and dispatch async IO requests. When an operation completes, it will put a completion message on the queue which your worker thread(s) can wait on and retrieve as they arrive. You can also put user defined messages into the queue. There is no limit to how many files or queued messages can be used with a completion port</li>\n<li>Dispatch each IO operation with an event. The event associated with an operation will become signaled (satisfy a wait) when it completes. Use <a href="http://msdn.microsoft.com/en-us/library/ms687025(VS.85).aspx" rel="noreferrer"><code>WaitForMultipleObjects</code></a> to wait on all the events at once. This has the disadvantage of only being able to wait on <code>MAXIMUM_WAIT_OBJECTS</code> objects at once (64). You can also wait on other types of events at the same time (process/thread termination, mutexes, events, semaphores)</li>\n<li>Use a <a href="http://msdn.microsoft.com/en-us/library/ms686760(VS.85).aspx" rel="noreferrer">thread pool</a>. The thread pool can take an unlimited number of objects and file operations to wait on and execute a <a href="http://msdn.microsoft.com/en-us/library/ms684124(VS.85).aspx" rel="noreferrer">user defined function</a> upon completion each.</li>\n<li>Use <code><a href="http://msdn.microsoft.com/en-us/library/aa365468(VS.85).aspx" rel="noreferrer">ReadFileEx</a></code> and <a href="http://msdn.microsoft.com/en-us/library/aa365748(VS.85).aspx" rel="noreferrer"><code>WriteFileEx</code></a> to queue <a href="http://msdn.microsoft.com/en-us/library/ms681951(VS.85).aspx" rel="noreferrer">Asynchronous Procedure Calls</a> (APCs) to the calling thread and <a href="http://msdn.microsoft.com/en-us/library/ms686307(VS.85).aspx" rel="noreferrer"><code>SleepEx</code></a> (or <code>WaitFor{Single|Multiple}ObjectsEx</code>) with <code>Alertable TRUE</code> to receive a notification message for each operation when it completes. This method is similar to an IO completion port, but only works for one thread.\n</ol>\n\n<p>The Windows NT kernel makes no distinction between socket, disk file, pipe, etc. file operations internally: all of these options will work with all the file types.</p>\n'}, {'answer_id': 11775658, 'author': 'Nouil', 'author_id': 1571097, 'author_profile': 'https://Stackoverflow.com/users/1571097', 'pm_score': 0, 'selected': False, 'text': '<p>select() function is POSIX and usable on windows including "winsock.h" or "winsock2.h". </p>\n'}, {'answer_id': 16034678, 'author': 'schlamar', 'author_id': 851737, 'author_profile': 'https://Stackoverflow.com/users/851737', 'pm_score': 3, 'selected': False, 'text': '<p><strong>libuv</strong></p>\n\n<p><code>libuv</code> offers evented I/O for Unix and Windows and has support for socket, files and pipes. It is the platform layer of Node.js.</p>\n\n<p>More details are at: <a href="http://nikhilm.github.io/uvbook/introduction.html" rel="noreferrer">http://nikhilm.github.io/uvbook/introduction.html</a></p>\n'}]
['https://Stackoverflow.com/questions/67082', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/9107/']