In order to perform nowait (asynchronous) socket I/O on an
HP 3000, a process must use the MPE XL IOWAIT and IODONTWAIT intrinsics. IOWAIT and IODONTWAIT behave in the same way except that, in the first
case, the calling process must wait until the I/O operation is complete;
in the second case, control is immediately returned to the calling
process. One of these intrinsics must be called at some point after
a nowait I/O request. The calling process is not blocked after the initial
nowait I/O request.
IPCSEND, IPCRECV, and IPCRECVCN are normally blocking calls. The calling process
must wait until the send/receive request is completed. A process
can use IPCCONTROL to enable nowait I/O for a specified call socket
or VC socket descriptor. (Nowait mode remains in effect until another IPCCONTROL call restores waited mode.) If a process issues
a nowait send or receive request, the request will be initiated
but its completion cannot be verified until IOWAIT or IODONTWAIT is called. (For a nowait IPCRECVCN call, the data structures for the connection are
not created until IOWAIT is called.) IPCCONNECT is always an unblocked call: control returns immediately
to the calling process, which must then call IPCRECV to complete the connection.
Within the IOWAIT/IODONTWAIT intrinsic, the filenum parameter should be given the appropriate call socket/VC
socket descriptor value. A value of zero indicates all sockets or
files for which asynchronous I/O requests have been issued. The
function value returned by the intrinsic is the descriptor (or file
number) for which the I/O has completed (zero if no completion).
The cstation (calling station) parameter returns a zero value for
any nowait receive request. For a nowait send request, bit one of
the parameter (the second highest bit) is set to on (all other bits
off). Therefore you can check bit one of the cstation parameter to determine whether an input or an output
operation completed.
The tcount parameter returns the amount of data received after
a nowait IPCRECV call. The target parameter is not currently used
by NetIPC.
The syntax for IOWAIT and IODONTWAIT is given here for convenience. For further information
on these intrinsics, please see the MPE XL Intrinsics
Reference Manual.
Steps for Programming with Asynchronous I/O |
|
The following summarizes the steps to follow to have your
program perform asynchronous I/O:
Create the call or VC socket with
IPCCREATE, IPCCONNECT, or IPCRECVCN.
Enable nowait I/O with IPCCONTROL.
Make a IPCRECVCN, IPCRECV, or IPCSEND NetIPC call on the socket. The call will be asynchronous.
Check the result code returned by the call to see if an error occurred
when the call was initiated.
Call IOWAIT to cause the calling process to wait until the
NetIPC call completes or IODONTWAIT to see if the request has completed.
Once the asynchronous NetIPC call completes do the
following:
Check the condition code to
see if an error occurred. If the condition code=CCE, no error occurred.
If the condition code <> CCE, an error occurred.
If an error occurred call IPCCHECK to determine the error code (returned in the
ipcerr parameter).
If IOWAIT or IDONTWAIT was called with filenum=0 or no filenum specified, check the fnum value returned to determine the socket for which I/O
completed. (You can compare the fnum value with the calldesc value returned by IPCCREATE and the vcdesc value returned by IPCCONNECT and IPCRECVCN.)