RSC/MP 7.2 Programming Manual
Application Development
HP NonStop Remote Server Call (RSC/MP) Programming Manual—522360-004
6-13
TMF Code Example
#include "rsc.h"
struct
 {
 SHORT nRequestType;
 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 uReplySize;
 SHORT nServerCode;
 SHORT nIoHandle;
 RscConnect ( RSC_DEFAULT_OPTIONS, RSC_CONNECT_WAITED, &ulConnect );
 RscBeginSession ( RSC_DEFAULT_OPTIONS, ulConnect, RSC_ST_INTERPROCESS, 
        RSC_BEGIN_WAITED, &ulSession );
 /****************************************************************************
  Explicit TMF transaction control
 ****************************************************************************/
 RscBeginTransaction ( ulConnect, 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 = RscSwapShort ( sReply.nRetcode );
 if ( ( nServerCode >= 0 && nServerCode <= 100 ) || nServerCode == 999 )
  RscEndTransaction ( ulConnect, ulSession );
 else
  RscAbortTransaction ( ulConnect, ulSession );
 }
 /* (application logic continues) */










