I\'m trying to implement named pipes in C++, but either my reader isn\'t reading anything, or my writer isn\'t writing anything (or both). Here\'s my reader:
A named pipe client can open the named pipe with CreateFile
-- but the named pipe server needs to use CreateNamedPipe
to create the named pipe. After it's created the named pipe, the server uses ConnectNamedPipe
to wait for a client to connect. Only after the client has connected should the server do a blocking read like your call to ReadFile
.
You must use CreateNamedPipe() to create the server end of a named pipe. Be sure to specify a non-zero buffer size, zero (documented by MSDN as 'use system default buffer size') doesn't work. MSDN has decent samples for a multi-threaded client&server.