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

The OS/2 API Project

DosConnectNPipe

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

Syntax

rc = DosConnectNPipe( hpipeHandle );

Parameters

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.

Returns

APIRET rc
The following values can be returned
0NO_ERROR
95ERROR_INTERRUPT
109ERROR_BROKEN_PIPE
230ERROR_BAD_PIPE
233ERROR_PIPE_NOT_CONNECTED

Include Info

#define INCL_DOSNMPIPES
#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

Gotchas

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

Author

Stefan Mars - mars@lysator.liu.se

Additions

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

The OS/2 API Project

DosConnectNPipe