HP 3000 Manuals

Exchanging Data [ Net IPC 3000/XL Programmer's Reference Manual ] MPE/iX 5.0 Documentation


Net IPC 3000/XL Programmer's Reference Manual

Exchanging Data 

The PTOP data-exchange calls are master-slave.  The master initiates an
exchange by calling  PWRITE (to send data to the slave),  PREAD (to
receive data from the slave) or  PCONTROL. The slave calls GET to receive
the request and ACCEPT to perform the actual data movement into or out of
its buffer.  Each of these operations may also exchange a tag between the
master and the slave.  The master call sends the master tag to the slave
and returns a tag from the slave.  The slave's GET call receives the
master tag.  The slave's ACCEPT or  REJECT call returns the slave's tag
to the master.

The  GET intrinsic can return an indication of the master request (0 =
error, 1 =  POPEN, 2 = PREAD, 3 =  PWRITE, 4 = PCONTROL). In many
applications, the slave will always know the next request that it will
receive from the master, so the function returned by  GET is superfluous.
But in some applications, the slave does not know in advance what the
next master request will be, and so it depends on the GET function to
decide on its response to the request.  The GET call can also return the
requested length of data to be sent or received.  These applications
typically have a loop with a GET that receives the master requests and a
case statement with cases for each of the different functions.

Data exchange with NetIPC is peer-to-peer.  A process on either side of a
virtual-circuit connection can send or receive data independently from
its partner.  The master-slave data exchange of PTOP can be simulated
using NetIPC calls.  For example, a PWRITE in the master can be replaced
by an IPCSEND, while the corresponding GET and  ACCEPT in the slave can
be replaced by an  IPCRECV. Tags can also be exchanged using sends and
receives.

In applications where the sequence of master requests is not known by the
slave, or where the length of data sent to or received from the slave is
not known, some information in addition to the exchanged data and tags
may need to be transmitted.  This includes a) a master request
indication, b) master request lengths, and c) the slave accept or reject
indication.

Because of the way that NetIPC stream mode operates on the HP 3000, an
IPCRECV may not receive all of the data requested.  For this reason, we
recommend that you write a procedure that calls  IPCRECV in a loop to
receive chunks of data until the entire requested amount is received.  An
example of this is in Chapter 4, NetIPC Examples, in this manual.

Exchanging Data:  In the Master Program 

To convert the PTOP intrinsic listed below, perform the following steps.

Syntax 
_________________________________________________
|                                               |
|                                               |
|     lgth := PREAD ( dsnum,target,tcount[,itag]|
|                                               |
_________________________________________________

 *  If the slave requires a master function, send the PREAD request
    function (=2) on the virtual circuit to the slave.

 *  If the slave requires the requested data length, send tcount on the
    virtual circuit.

 *  If a tag is specified, send the master tag on the virtual circuit.

 *  If the master needs to know the actual data length sent from the
    slave, receive the actual data length from the virtual circuit.

 *  If the slave may call either  ACCEPT or REJECT, receive a one byte
    accept or reject indication on the virtual circuit from the slave.
    Otherwise assume the slave accepted the request.

 *  If the slave accepted the request, receive the target data from the
    slave, using either a predetermined length or the actual data length
    received in Step 4.

 *  If a tag is specified, receive the slave tag from the virtual
    circuit.

To convert the PTOP intrinsic listed below, perform the following steps:

Syntax 
____________________________________________
|                                          |
|     PWRITE( dsnum, target, tcount[, itag]|
|                                          |
____________________________________________

 *  If the slave requires a master function, send the PWRITE request
    function (=3) on the virtual circuit to the slave.

 *  If the slave requires the requested data length, send tcount on the
    virtual circuit.

 *  If a tag is specified, send the master tag on the virtual circuit.

 *  If the slave may call either  ACCEPT or REJECT, receive a one byte
    accept or reject indication on the virtual circuit from the slave,
    Otherwise assume the slave accepted the request.

 *  If the slave accepted the requested, send the target data on the
    virtual circuit to the slave, using the  tcount length.

 *  If a tag is specified, receive the slave tag from the virtual
    circuit.

To convert the PTOP intrinsic listed below, perform the following steps.

Syntax 
_____________________________________
|                                   |
|                                   |
|     PCONTROL ( dsnum[, itag]      |
|                                   |
_____________________________________

 *  If the slave requires a master function, send the PCONTROL request
    function (=4) on the virtual circuit to the slave.

 *  If a tag is specified, send the master tag on the virtual circuit,
    and receive the slave tag from the virtual circuit.

Exchanging Data:  In the Slave Program 

To convert the PTOP intrinsic listed below, perform the following steps.

Syntax 
_______________________________________________
|                                             |
|                                             |
|     ifun :=  GET [([ itag][, il][, ionumber]|
|                                             |
_______________________________________________

 *  If the slave requires a master function, receive a one byte master
    function number from the virtual circuit from the master.

 *  If the slave requires the request length, receive the length from the
    virtual circuit.

 *  If a tag is specified, receive the master tag from the virtual
    circuit.

To convert the PTOP intrinsic listed below, perform the following steps.

Syntax 
__________________________________________
|                                        |
|                                        |
|     ACCEPT [([ itag[, target][,tcount)]|
|                                        |
__________________________________________

 *  Depending on the master function, either known to the application, or
    received from the master in Step (1):

 PREAD: Send the target data, of length fncttcount, on the virtual
circuit to the master.

 PWRITE: Receive the data into target, using either the known fncttcount
or the length received from the master in Step (2).

 *  If a tag is specified, send the slave tag on the virtual circuit.



MPE/iX 5.0 Documentation