beautypg.com

Compaq Reliable Transaction Router User Manual

Page 57

background image

Application Programming Interfaces

Sample C++
server code

Example of object creation in an RTR server program.

void CombinationOrderProcessor::StartProcessingOrdersAtoL()
{
//
// Create an RTRKeySegment for all ASCII values between "A" and "L."
//
m_pkeyRange = new RTRKeySegment (rtr_keyseg_string, //To process strings.

1,

//Length of the key.

OffsetIntoApplicationProtocol, //Offset value.
"A",

//Lowest ASCII value for partition.

"L");

//Highest ASCII value for partition.

StartProcessingOrders(PARTITION_NAMEAToL,m_pKeyRange);
}

//
// Create an RTRData Oobject to hold each incoming message or event. This
// object will be reused.
//
RTRData *pDataReceived= new RTRData();
//
// Continually loop, receiving messages and dispatching them to the handlers.
//
while(true)
{

sStatus = pTransaction->Receive(&pDataReceived);
ASSERT(RTR_STS_OK == sStatus);

sStatus = pDataReceived->Dispatch();
ASSERT(RTR_STS_OK == sStatus);

}

RTR C
Programming
Interface

You can use the C programming interface to write C applications
that use RTR. For more information on the C programming
interface, see the RTR C Application Programmer’s Reference
Manual
and the RTR Application Design Guide.

Snippets from client and server programs using the RTR C-
programing API follow and are more fully shown in the RTR
Application Design Guide.

RTR Interfaces 4–9