title: IO completion port key confusion
body: <p>I'm writing an IO completion port based server (<a href="http://code.google.com/p/pyiocp/source/browse/01%20-%20Work%20in%20Progress/03%20-%20Serving.py" rel="noreferrer">source code here</a>) using the Windows DLL API in Python using the ctypes module.  But this is a pretty direct usage of the API and this question is directed at those who have a knowledge of IOCP, not Python.</p>
  
  <p>As I understand the documentation for CreateIoCompletionPort, you specify your "user defined" completion key when you call this function with a file handle (in my case a socket) you are associating with the created IOCP.  When you get around to calling GetQueuedCompletionStatus, you get a completion key value along with a pointer to an overlapped object.  The completion key should identify what overlapped object and request has completed.</p>
  
  <p>However, let's say I pass in 100 as the completion key in my CreateIoCompletionPort call with an overlapped object.  When the same overlapped object has its IO completed and it arrives back through GetQueuedCompletionStatus, the completion key that accompanies it is much larger and bares no resemblance to the original value of 100.</p>
  
  <p>Am I misunderstanding how the completion key works, or must I be doing it wrong in the source code I linked above?</p>