Create a named pipe with a unique named.
I might be missing something, but I don't see any code here that creates a "unique named" pipe. Nonetheless, that seems like a somewhat strange requirement. The point of a named pipe is that you know its name ahead of time, and you can use it from separate processes. If you only want a temporary pipe to communicate between two processes, a named pipe doesn't seem like the right thing. Again, from your code, it doesn't really look like that's what you're doing, but your text description seemed a bit strange.