DisconnectNamedPipe

  BOOL DisconnectNamedPipe(hNamedPipe)    
  HANDLE hNamedPipe; /* named-pipe handle */

The DisconnectNamedPipe function disconnects the server side of a named pipe instance.

Parameters

hNamedPipe

Identifies an instance of a named pipe. This handle must have been created by the CreateNamedPipe function.

Return Value

The return value is TRUE if the function is successful. Otherwise, it is FALSE in which case extended error information is available from the GetLastError function.

Comments

If the client end of the named pipe is open, the DisconnectNamedPipe function forces that end of the named pipe closed. The client will receive an error the next time it attempts to access the pipe. Disconnecting the pipe may discard data in the pipe before the client reads it. The server can use the FlushFileBuffers function to make sure data is not lost.

A client that is forced off a pipe by the DisconnectNamedPipe function must still close its end of the pipe with the CloseHandle function.

DisconnectNamedPipe changes the state of the pipe instance to Disconnected. The server can call ConnectNamedPipe to change the state to Listening so the instance can connect to another client.

See Also

ConnectNamedPipe, FlushFileBuffers