[ Home | Alpha index | Topic index | Tutorials | Download | Feedback ]

The OS/2 API Project


[ Syntax | Params | Returns | Include | Usage | Structs | Gotchas | Code | Also ]


rc = DosConnectNPipe( hpipeHandle );


HPIPE hpipeHandle (input)
This is the handle used to connect to a named pipe. It must be the same handle as returned by a previous call to DosCreateNPipe.


The following values can be returned

Include Info

#include <os2.h>

Usage Explanation

A server process should use DosConnectNPipe to set a named pipe listening. If this is not done, client processes will be unable to gain access to the pipe using DosOpen or DosCallNPipe. If the pipe's client end is already open, DosConnectNPipe will have no effect. If the client end is closed the result of calling DosConnectNPipe will depend on the pipe being in blocking or non-blocking mode. Blocking/non-blocking mode for the pipe was specified when it was created, or later set using DosSetNPHState.

If the pipe is in blocking mode, DosConnectNPipe will wait for a client to connect before returning.

If the pipe is in nonblocking mode, DosConnectNPipe will return at once with an error, in this case ERROR_PIPE_NOT_CONNECTED. However, the pipe will have been set listening, thereby letting a client succesfully use DosOpen.

ERROR_BROKEN_PIPE is returned if the pipe was opened, and then closed by a client, but not yet disconnected from the server.

ERROR_INTERRUPT is returned if the function was interrupted while waiting for a client to open the pipe.

If a client process is calling DosConnectNPipe the error ERROR_BAD_PIPE is returned.

Relevant Structures


Sample Code

#define INCL_DOSNMPIPES #include <os2.h> HPIPE Handle; /* The pipe handle */ APIRET rc; /* Just to take care of the return code. */ /* We assume the pipe handle has been returned by DosCreateNPipe, and */ /* stored in the variable Handle. We also assume the pipe was set to */ /* blocking mode, and that no client has opened it yet. */ rc = DosConnectNPipe( Handle); /* With this call to DosConnectNPipe we wait for a client to connect to */ /* the named pipe. */ if (rc != 0) { /* We have an error we must take care of. */ }

See Also

DosCallNPipe, DosCreateNPipe, DosDisConnectNPipe, DosPeekNPipe, DosQueryNPHState, DosQueryNPipeInfo, DosQueryNPipeSemState, DosSetNPHState, DosSetNPipeSem, DosTransactNPipe, DosWaitNPipe, DosClose, DosDupHandle, DosOpen, DosRead, DosResetBuffer, DosWrite


Stefan Mars - mars@lysator.liu.se


Last modified March 17/1996
Please send all errors, comments, and suggestions to: timur@vnet.ibm.com

The OS/2 API Project