Jump to content

DosCallNPipe: Difference between revisions

From EDM2
Created page with "==Description== Makes a procedure call to a duplex message pipe. ==Syntax== <PRE> #define INCL_DOSNMPIPES #include <os2.h> PSZ pszName; /* The ASCIIZ name of the p..."
 
Ak120 (talk | contribs)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Description==
Makes a procedure call to a duplex message pipe.
Makes a procedure call to a duplex message pipe.


==Syntax==
==Syntax==
<PRE>
  DosCallNPipe(pszName, pInbuf, cbIn, pOutbuf, cbOut, pcbActual, msec)
#define INCL_DOSNMPIPES
#include <os2.h>
 
PSZ      pszName;    /*  The ASCIIZ name of the pipe to be opened. */
PVOID    pInbuf;    /*  A pointer to the buffer that is to be written to the pipe. */
ULONG    cbIn;      /*  The number of bytes to be written. */
PVOID    pOutbuf;    /*  A pointer to the buffer for returned data. */
ULONG    cbOut;      /*  The maximum size, in bytes, of returned data. */
PULONG    pcbActual;  /*  A pointer to the ULONG in which the number of bytes actually read is returned. */
ULONG    msec;      /*  The maximum time, in milliseconds, to wait for a pipe instance to become available. */
APIRET    ulrc;      /* Return Code. */
 
ulrc = DosCallNPipe(pszName, pInbuf, cbIn,
        pOutbuf, cbOut, pcbActual, msec);


</PRE>
==Parameters==
==Parameters==
; pszName (PSZ) - input : The ASCIIZ name of the pipe to be opened.
;pszName (PSZ) - input: The ASCIIZ name of the pipe to be opened.
Pipe names must include the prefix \PIPE\ and must conform to file-system naming conventions. When communicating with a remote process, the computer name must also be included, using the format \\ComputerName\PIPE\FileName.  
:Pipe names must include the prefix \PIPE\ and must conform to file-system naming conventions. When communicating with a remote process, the computer name must also be included, using the format \\ComputerName\PIPE\FileName.
 
;pInbuf (PVOID) - input: A pointer to the buffer that is to be written to the pipe.
; pInbuf (PVOID) - input : A pointer to the buffer that is to be written to the pipe.  
;cbIn (ULONG) - input: The number of bytes to be written.
 
;pOutbuf (PVOID) - output: A pointer to the buffer for returned data.
; cbIn (ULONG) - input : The number of bytes to be written.  
;cbOut (ULONG) - input: The maximum size, in bytes, of returned data.
 
;pcbActual (PULONG) - output: A pointer to the ULONG in which the number of bytes actually read is returned.
; pOutbuf (PVOID) - output : A pointer to the buffer for returned data.  
;msec (ULONG) - input: The maximum time, in milliseconds, to wait for a pipe instance to become available.
 
; cbOut (ULONG) - input : The maximum size, in bytes, of returned data.  
 
; pcbActual (PULONG) - output : A pointer to the ULONG in which the number of bytes actually read is returned.  
 
; msec (ULONG) - input : The maximum time, in milliseconds, to wait for a pipe instance to become available.  


==Return Code==
==Return Code==
ulrc (APIRET) - returns
;ulrc (APIRET) - returns:DosCallNPipe returns one of the following values:
 
* 0 NO_ERROR
DosCallNPipe returns one of the following values:
* 2 ERROR_FILE_NOT_FOUND
 
* 3 ERROR_PATH_NOT_FOUND
* 0       NO_ERROR  
* 5 ERROR_ACCESS_DENIED
* 2       ERROR_FILE_NOT_FOUND  
* 11 ERROR_BAD_FORMAT
* 3       ERROR_PATH_NOT_FOUND  
* 95 ERROR_INTERRUPT
* 5       ERROR_ACCESS_DENIED  
*230 ERROR_BAD_PIPE
* 11       ERROR_BAD_FORMAT  
*231 ERROR_PIPE_BUSY
* 95       ERROR_INTERRUPT  
*233 ERROR_PIPE_NOT_CONNECTED
* 230       ERROR_BAD_PIPE  
*234 ERROR_MORE_DATA
* 231       ERROR_PIPE_BUSY  
* 233       ERROR_PIPE_NOT_CONNECTED  
* 234       ERROR_MORE_DATA  
 
On the PowerPC platform, DosCallNPipe fails with error code ERROR_PATH_NOT_FOUND when the pipe name contains more than one \ in the name. For example, the following pipe name would cause DosCallNPipe to fail:
On the PowerPC platform, DosCallNPipe fails with error code ERROR_PATH_NOT_FOUND when the pipe name contains more than one \ in the name. For example, the following pipe name would cause DosCallNPipe to fail:
 
\pipe\\\\\longname.nam
      \pipe\\\\\longname.nam


==Remarks==
==Remarks==
Line 73: Line 46:
==Example Code==
==Example Code==
This example shows how to make a call to an existing named pipe.
This example shows how to make a call to an existing named pipe.
Before running this example, compile and run the example code shown in the DosConnectNPipe, DosCreateNPipe, DosDisConnectNPipe, or DosSetNPipeSem functions.
<PRE>
<PRE>
Before running this example, compile and run the example code shown in the DosConnectNPipe, DosCreateNPipe, DosDisConnectNPipe, or DosSetNPipeSem functions.
#define INCL_DOSFILEMGR      /* DOS File Manager values */
#define INCL_DOSFILEMGR      /* DOS File Manager values */
#define INCL_DOSNMPIPES      /* DOS Named Pipes values */
#define INCL_DOSNMPIPES      /* DOS Named Pipes values */
Line 118: Line 91:
   return NO_ERROR;
   return NO_ERROR;
}
}
</PRE>


</PRE>
==Related Functions==
==Related Functions==
* [[OS2 API:CPI:DosConnectNPipe|CPI:DosConnectNPipe]]
*[[DosConnectNPipe]]
* [[OS2 API:CPI:DosClose|CPI:DosClose]]
*[[DosClose]]
* [[OS2 API:CPI:DosCreateNPipe|CPI:DosCreateNPipe]]
*[[DosCreateNPipe]]
* [[OS2 API:CPI:DosDisConnectNPipe|CPI:DosDisConnectNPipe]]
*[[DosDisConnectNPipe]]
* [[OS2 API:CPI:DosDupHandle|CPI:DosDupHandle]]
*[[DosDupHandle]]
* [[OS2 API:CPI:DosOpen|CPI:DosOpen]]
*[[DosOpen]]
* [[OS2 API:CPI:DosPeekNPipe|CPI:DosPeekNPipe]]
*[[DosPeekNPipe]]
* [[OS2 API:CPI:DosQueryNPHState|CPI:DosQueryNPHState]]
*[[DosQueryNPHState]]
* [[OS2 API:CPI:DosQueryNPipeInfo|CPI:DosQueryNPipeInfo]]
*[[DosQueryNPipeInfo]]
* [[OS2 API:CPI:DosQueryNPipeSemState|CPI:DosQueryNPipeSemState]]
*[[DosQueryNPipeSemState]]
* [[OS2 API:CPI:DosRead|CPI:DosRead]]
*[[DosRead]]
* [[OS2 API:CPI:DosResetBuffer|CPI:DosResetBuffer]]
*[[DosResetBuffer]]
* [[OS2 API:CPI:DosSetNPHState|CPI:DosSetNPHState]]
*[[DosSetNPHState]]
* [[OS2 API:CPI:DosSetNPipeSem|CPI:DosSetNPipeSem]]
*[[DosSetNPipeSem]]
* [[OS2 API:CPI:DosTransactNPipe|CPI:DosTransactNPipe]]
*[[DosTransactNPipe]]
* [[OS2 API:CPI:DosWaitNPipe|CPI:DosWaitNPipe]]
*[[DosWaitNPipe]]
* [[OS2 API:CPI:DosWrite|CPI:DosWrite]]
*[[DosWrite]]
 


[[Category:The OS/2 API Project]]
[[Category:Dos]]

Latest revision as of 20:27, 29 November 2019

Makes a procedure call to a duplex message pipe.

Syntax

DosCallNPipe(pszName, pInbuf, cbIn, pOutbuf, cbOut, pcbActual, msec)

Parameters

pszName (PSZ) - input
The ASCIIZ name of the pipe to be opened.
Pipe names must include the prefix \PIPE\ and must conform to file-system naming conventions. When communicating with a remote process, the computer name must also be included, using the format \\ComputerName\PIPE\FileName.
pInbuf (PVOID) - input
A pointer to the buffer that is to be written to the pipe.
cbIn (ULONG) - input
The number of bytes to be written.
pOutbuf (PVOID) - output
A pointer to the buffer for returned data.
cbOut (ULONG) - input
The maximum size, in bytes, of returned data.
pcbActual (PULONG) - output
A pointer to the ULONG in which the number of bytes actually read is returned.
msec (ULONG) - input
The maximum time, in milliseconds, to wait for a pipe instance to become available.

Return Code

ulrc (APIRET) - returns
DosCallNPipe returns one of the following values:
  • 0 NO_ERROR
  • 2 ERROR_FILE_NOT_FOUND
  • 3 ERROR_PATH_NOT_FOUND
  • 5 ERROR_ACCESS_DENIED
  • 11 ERROR_BAD_FORMAT
  • 95 ERROR_INTERRUPT
  • 230 ERROR_BAD_PIPE
  • 231 ERROR_PIPE_BUSY
  • 233 ERROR_PIPE_NOT_CONNECTED
  • 234 ERROR_MORE_DATA

On the PowerPC platform, DosCallNPipe fails with error code ERROR_PATH_NOT_FOUND when the pipe name contains more than one \ in the name. For example, the following pipe name would cause DosCallNPipe to fail:

\pipe\\\\\longname.nam

Remarks

DosCallNPipe combines the functions of DosOpen, DosTransactNPipe, and DosClose for a duplex message pipe. If no instances of a pipe are available, DosCallNPipe waits for a specified time interval, and returns ERROR_INTERRUPT if the time interval elapses.

If this function is issued for a pipe that is not a duplex message pipe, ERROR_BAD_FORMAT is returned.

If an invalid pipe name is specified, DosCallNPipe returns ERROR_FILE_NOT_FOUND.

If pOutbuf is too small to contain the response message, ERROR_MORE_DATA is returned.

If the server process has not issued DosConnectNPipe to put the pipe into a listening state, DosCallNPipe returns ERROR_PIPE_BUSY.

Clients of named pipes created with the NP_ACCESS_OUTBOUND or NP_ACCESS_INBOUND access mode cannot use the DosCallNPipe function. If the named pipe's client uses the DosCallNPipe function, the function returns error code ERROR_ACCESS_DENIED.

ERROR_BAD_PIPE is returned if you specify an invalid name or file handle.

Example Code

This example shows how to make a call to an existing named pipe.

Before running this example, compile and run the example code shown in the DosConnectNPipe, DosCreateNPipe, DosDisConnectNPipe, or DosSetNPipeSem functions.

#define INCL_DOSFILEMGR       /* DOS File Manager values */
#define INCL_DOSNMPIPES       /* DOS Named Pipes values */
#define INCL_DOSSEMAPHORES    /* DOS Semaphore values */
#define INCL_DOSERRORS        /* DOS Error values */
#include <os2.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(VOID) {
   APIRET   rc                     = NO_ERROR;   /* Return code */
   CHAR     outmsg[256]            = "";         /* Output message buffer */
   CHAR     inmsg[256]             = "";         /* Input message buffer */
   HFILE    PipeHandle             = NULLHANDLE; /* Pipe handle */
   PIPEINFO PipeBuffer[4]          = {{0}};
   struct   _AVAILDATA  BytesAvail = {0};
   UCHAR    Buffer[200]            = {0};
   ULONG    bytes                  = 0;
   ULONG    Action                 = 0;
   PIPESEMSTATE infobuf[3]         = {{0}};

   printf("Enter message to send to PIPEHOST: ");

   fflush(NULL);   /* Make above printf show on display */
   gets(outmsg);

   rc = DosCallNPipe("\\PIPE\\EXAMPLE",   /* Name of duplex pipe */
                      outmsg,             /* Output message buffer */
                      strlen(outmsg),     /* Size of output message */
                      inmsg,              /* Input message buffer */
                      sizeof(inmsg),      /* Size of input buffer */
                      &bytes,             /* Number of bytes read */
                      30000L);            /* Wait 30 seconds for pipe */
   if (rc != NO_ERROR) {
      printf("DosCallNPipe error: error code = %u\n", rc);
      return 1;
   } else {
      printf("\nMessage received from PIPEHOST: %s\n\n", inmsg);
   } /* endif */

   return NO_ERROR;
}

Related Functions