RSC/MP Programming Manual

Application Development
TMF Code Example
#include "rsc.h"
struct
{
SHORT nRequestTy pe;
char acData[512];
} sRequest;
/* For "automatic" transaction control, the server return code must
* be a signed value in the first two bytes of the reply
*/
struct
{
SHORT nRetcode;
char acData[256];
} sReply;
int main ( void )
{
USHORT rc;
ULONG ulConnect;
ULONG ulSession;
ULONG ulOptions;
USHORT uRe plySiz e;
SHORT nServerCo de;
SHORT nIoHandle;
RscConnect ( RSC_DEFAULT_OPTIONS, RSC_CONNECT_WA ITED, &ulConnect );
RscBeginSession ( RSC_DEFAULT_OPT IONS, u lConne ct, RS C_ST_I NTERP ROCESS,
RSC_BEGIN_WAITED, &ulSession );
/********* ****** **** ******* ****** ************* ****** *********** ****** ********
Explicit T MF tra nsac tion co ntrol
********** ****** **** ******* ****** ************* ****** *********** ****** *******/
RscBeginTr ansact ion ( ulCon nect, ulSession );
uReplySize = sizeof ( sReply );
rc = RscWriteRead ( RSC_DEFAULT_OPTIONS, ulConnect, ulSession, "$XYZ",
RSC_IO_WAITED, &sRequest, sizeof(sRequest), &sReply,
&uReplySize );
if ( rc == RSC_SUCCESS )
{
/* Examine server return code; commit or roll back accordingly */
nServerCode = RscSwapSh ort ( sReply.nRetcode );
if ( ( nServerCode >= 0 && nServerCode <= 100 ) || nServerCode == 999 )
RscEndTransaction ( ulConnect, ulSession );
else
RscAbortTransaction ( ulConnect, ulSession );
}
/* (application logic continues) */
HP NonStop Remote Server Call (RSC/MP) Programming Manual 522360-006
6- 13