#define    NPIPE_NAME   "\\PIPE\\SRVPIPE"                                      /* Pipe name             */

HFILE      Pipe;                                                               /* Pipe handle           */
PREQUEST   Request;                                                            /* Request buffer ptr    */
PREPLY     Reply;                                                              /* Reply buffer ptr      */
ULONG      Bytes;                                                              /* Bytes read/written    */
APIRET     Rc;                                                                 /* Return code           */

Rc = DosCreateNPipe (NPIPE_NAME,                                               /* Create named pipe     */
                     &Pipe,                                                    /* Pipe handle           */
                     NP_ACCESS_DUPLEX,                                         /* Allow duplex access   */
                     NP_WAIT             |                                     /* Blocking mode         */
                     NP_TYPE_MESSAGE     |                                     /* Msg oriented pipe     */
                     NP_READMODE_MESSAGE |                                     /* Msg oriented read     */
                     0x01,                                                     /* Pipe for one client   */
                     sizeof (REPLY),                                           /* Outbound buffer size  */
                     sizeof (REQUEST),                                         /* Inbound buffer size   */
                     0);                                                       /* Default timeout value */

while (...)                                                                    /* Until process ends    */
{
  Rc = DosConnectNPipe (Pipe);                                                 /* Connect to requester  */

  Rc = DosRead (Pipe,                                                          /* Read request          */
                Request,                                                       /* Request buffer        */
                sizeof (REQUEST),                                              /* Size of buffer        */
                &Bytes);                                                       /* No. of bytes read     */

  CompleteRequest (Request, Reply);                                            /* Complete request      */

  Rc = DosWrite (Pipe,                                                         /* Write reply to pipe   */
                 Reply,                                                        /* Reply buffer          */
                 sizeof (REPLY),                                               /* Size of buffer        */
                 &Bytes);                                                      /* No. of bytes written  */

  Rc = DosDisConnectNPipe (Pipe);                                              /* Disconnect from req   */
}
