#define NPIPE_NAME "\\PIPE\\SRVPIPE" /* Pipe name */
void RequestThread(TRANS *Trans) /* Requester thread */
{
ULONG ulBytes; /* Bytes read/written */
APIRET rc; /* Return code */
rc = DosWaitNPipe(NPIPE_NAME, /* Wait on named pipe */
NP_WAIT_INDEFINITELY); /* Wait indefinitely */
rc = DosCallNPipe(NPIPE_NAME, /* Pipe name */
Trans->Request, /* Request buffer ptr */
sizeof(REQUEST), /* Size of buffer */
Trans->Reply, /* Reply buffer ptr */
sizeof(REPLY), /* Size of buffer */
&ulBytes, /* No. of bytes read */
10000); /* Timeout period */
WinPostMsg(Trans->hReturn, /* Notify calling window */
WMP_REQUESTCOMPLETE, /* Request is complete */
(MPARAM)Trans, /* Transaction structure */
0);
DosExit(0);
}
This example shows a secondary thread in a "requester" process, writing to and reading from a named pipe.