RPC HELP DLL GuideLines CPP Connect to the Server

RPC Broker Help Home

DLL Interface Home C++: Connect to the Server

To connect to the VistA M Server from your C++ program:

1. Set the server and port to connect to:

// Set the Server and Port properties to determine where to connect. RPCInst.RPCBPropSet("Server", server); RPCInst.RPCBPropSet("ListenerPort", "9200");

2. Set the Connected property to true; this attempts a connection to the VistA M Server:

// Set the Connected property to True, to connect. RPCInst.RPCBPropSet("Connected", "1");

3. Check if you are still connected. If so, you can continue (your connection was made). If not, you should quit or branch accordingly:

// If still connected, can continue. RPCInst.RPCBPropGet("Connected", Value); if (atoi(Value) != 1) return false;

4. Attempt to create context for your application's "B"-type option. If you can't create context, you should quit or branch accordingly. If RPCBCreateContext returns True, then you are ready to call all RPCs registered to your application's "B"-type option:

// Create Context for your application's option (in this case, XWB EGCHO). result = RPCInst.RPCBCreateContext("XWB EGCHO"); return result;