How come WPUQueueApc returns WSAEOPNOTSUPP for Windows CE



The Windows CE OS does not support APC's therefore winsock2 also can't support them. The workaround is to create a thread to call the callback function. This is similar to queueing an APC, but of course the callback will happen on a different thread than the calling thread. This can create synchronization problems for code that expects the callback to happen on the same thread and therefore doesn't use synchronization mechanisms (like critical sections). There is also the overhead of creating a new thread.


For these reasons using callback functions is not really encouraged on Windows CE, but it is still supported to the extent mentioned above. The logic being that those who have code working on the desktop may be porting their code over to CE, and it may be easier for them to provide the synchronization mechanisms than changing their code to use events.


So what should you do if you have an LSP and want to do callbacks? If your LSP is in a chain where the base provider in the chain is the Windows CE base provider (ie: wspm.dll) then wspm will already spawn a thread, and your LSP should just be able to use that thread to do the callback. Otherwise if an underlying LSP or base provider doesn't create the thread you may have to do that in your LSP.

Skip to main content