iocp

An IOCP documentation interpretation question - buffer ownership ambiguity

Since I'm not a native English speaker I might be missing something so maybe someone here knows better than me. Taken from WSASend's doumentation at MSDN: lpBuffers [in] A pointer to an array of WSABUF structures. Each WSABUF structure contains a pointer to a buffer and the length, in bytes, of the buffer. For a Winsock...

WSASend() with more than one buffer - could complete incomplete?

Say I post the following WSASend call (Windows I/O completion ports without callback functions): void send_data() { WSABUF wsaBuff[2]; wsaBuff[0].len = 20; wsaBuff[1].len = 25; WSASend(sock, &wsaBuff[0], 2, ......); } When I get the "write_done" notification from the completion port, is it possible that wsaBuff[1] will...

ConnectEx with IOCP problem

I've made a simple dummy server/dummy client program using IOCP for some testing/profiling purpose. (And I also wanted to note that I'm new to asynchronous network programming) It looks like the server works well with original client, but when the dummy client tries to connect to the server with ConnectEx function, IOCP Worker thread st...

Timer that supports overlapped I/O (for IOCP) ?

Hello, I need to add timers support in an application based on I/O Completion Ports (IOCP). I would like to avoid the use of a specific thread to manage timers. On Linux, you can create a timer that delivers expiration notifications via a file descriptor (see timerfd.h man), so it's great to use it for example with epoll if your applic...

Using iocp in a job pool

When using iocp in a job/task pool to provide fast worker wake ups what is the best way to minimise the overhead of signalling the port - ie not having to do it every queue operation? void Worker() { while(1) { for(int spin = 0; spin < 5000; ++spin) while(queue.Count > 0) queue.PopFront()(); ...

Can I/O completion port help with database instead of File writes?

I am reading up on IOCP, and from what I understand so far, the asynchronous writes only apply in the context of writing to Files. By "Files", I don't mean just disk file, but "File" type output devices on Windows. I am planning to somehow use IOCP in implementing a server that takes messages from clients and then writes those messages ...

How do I properly shut down an IOCP server?

I can find tonnes of article's about starting up an IOCP server, but none about properly shutting it down =/ What is the proper way to shut the server down when you are done? more specifically, I already use PostQueuedCompletionStatus() to tell the worker threads to quit, but don't I also need to cancel all the pending IO, and close all...

Windows IOCP - any advantage for single-socket application?

As I understand IOCP under Windows Server 2003/2008 and C++ programming, they are more-or-less the highest performance way to service either multiple sockets, instead of select, or to tie together multiple threads to service those requests. If my program has but a single socket however, and given other constraints will generally read on...

How to find out when CancelIo() is done?

UPDATE: CancelIo() works fine. I misunderstood my code. See the accepted answer for more details. CancelIo() is supposed to cancel all pending I/O operations associated with the calling thread. In my experience, CancelIo() sometimes cancels future I/O operations as well. Given: ReadFile(port, buffer, length, &bytesTransferred, overlapp...

TransmitFile + SChannel

I'm using the TransmitFile API with I/O completion ports for an efficient multithreaded file server on Windows. This all works fine, but I've now also implemented secure sockets using SChannel. Because TransmitFile streams the file directly to the socket, I don't see a way to call EncryptMessage - will I need to read the file in chunks,...