ConnectNamedPipe

 

Contents

Description

Enables a named pipe server process to wait for a client process to connect to an instance of a named pipe. A client process connects by calling either the CreateFile or CallNamedPipe function.

Syntax

BOOL ConnectNamedPipe( HANDLE hNamedPipe, LPOVERLAPPED lpOverlapped )

Parameters

hNamedPipe
[input] A handle to the server end of a named pipe instance. This handle is returned by the CreateNamedPipe function.
lpOverlapped
[input] A pointer to an OVERLAPPED structure.

Return

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Examples

Remark

A named pipe server process can use ConnectNamedPipe with a newly created pipe instance. It can also be used with an instance that was previously connected to another client process; in this case, the server process must first call the DisconnectNamedPipe function to disconnect the handle from the previous client before the handle can be reconnected to a new client. Otherwise, ConnectNamedPipe returns zero, and GetLastError returns ERROR_NO_DATA if the previous client has closed its handle or ERROR_PIPE_CONNECTED if it has not closed its handle.

See Also

CallNamedPipe,CreateNamedPipe

header to Include

origin.h

Reference