I use a named pipe and I want to reuse the same pipe on the server to allow connecting another client once the original client has disconnected. What I do is:
- server creates a pipe using
CreateNamedPipe - server writes data using
WriteFile, and retries doing so as long as errorERROR_PIPE_LISTENINGis returned (which is before any client is connected) - clients connects using
CreateFile - client reads data
- client close pipe handle using
CloseHandle - at this point server gets error
ERROR_NO_DATAwhen it attemps to write more data - server disconnects the pipe using
DisconnectNamedPipe, which I hoped should make it free again - server tries writing data, gets error
ERROR_PIPE_NOT_CONNECTED, it retries doing so until there is no error - however, when new client connects, and attempts
CreateFileon the pipe, it getsERROR_PIPE_BUSY
Hence, my question is: what other steps I need to do to disconnect client from the pipe properly so that a new client can connect?