I associate an HANDLE "h_server" that I create with CreateNamedPipe() with an I/O Completion Port, and
for the completion key I use a function pointer: namedpipe_server_completion_routine().
Now, when a named pipe client connection request triggers, that HANDLE "h_server" became the client endpoint
in the named pipe server application, so I should change its I/O Completion Key to another kind of routine pointer, the one that completes I/O, Read, Write etc, io_arrival_completion_routine(), which is different from the named pipe server completion routine.
I thought to call again CreateIoCompletionPort() with the new completion key on that HANDLE, but it seems not working, so there is a way to change that key? Maybe with some hacks with DuplicateHandle or something?
If not, how I could solve this?
NOTE: this problem is only present with named pipe servers, because AcceptEx() works in a different way: with tcp servers, when a connection arrives, you basically got a new HANDLE for the client endpoint on the server, so you can associate that new HANDLE with the io completion port and the correct completion key as the correct io_arrival_completion_routine(), while the HANDLE of the tcp server associated with the tcp_server_completion_routine() will remain correct, and its unique role will be to listen for new connections.