6.3.1.1 Example: Sending an Asynchronous Message with TPNOTRAN | TPNOREPLY
The following listing shows how tpacall()
uses the TPNOTRAN
and TPNOREPLY
flags. This code is similar to the code in Example: Sending a Synchronous Message with TPNOTRAN Set. In this case, however, a reply is not expected from the PRINTER
service. By setting both TPNOTRAN
and TPNOREPLY
flags, the client is indicating that no reply is expected and the PRINTER
service will not participate in the current transaction. This situation is discussed more fully in Managing Errors.
Listing Sending an Asynchronous Message with TPNOREPLY | TPNOTRAN
#include <stdio.h>
#include "atmi.h"
main()
{
char *rbuf; /* report buffer */
long rlen, rrlen; /* buffer lengths of send, reply buffers for report */
join application
if (rbuf = tpalloc("STRING", NULL, 0) == NULL) /* allocate space for report
*/
error
(void)strcpy(rbuf, "REPORT=accrcv DBNAME=accounts");/* send parms of report
*/
rlen = strlen(rbuf)+1; /* length of request */
start transaction
if (tpcall("REPORT", rbuf, rlen, &rbuf, &rrlen, 0)
== -1) /* get report print stream */
error
if (tpacall("PRINTER", rbuf, rrlen, TPNOTRAN|TPNOREPLY)
== -1) /* send report to printer */
error
. . .
commit transaction
free buffer
leave application
}
Parent topic: Sending an Asynchronous Request