Difference between revisions of "RPC HELP DLL GuideLines C Connect to the Server"
From VistApedia
(Created page with " RPC Broker Help Home DLL Interface Home") |
|||
Line 2: | Line 2: | ||
[[RPC_HELP_Other_DLL_Interface_List|DLL Interface Home]] | [[RPC_HELP_Other_DLL_Interface_List|DLL Interface Home]] | ||
+ | <h2>C: Connect to the Server</h2> | ||
+ | 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. | ||
+ | RPCBPropSet(RPCBroker,"Server", "BROKERSERVER"); | ||
+ | RPCBPropSet(RPCBroker, "ListenerPort", "9200"); | ||
+ | |||
+ | '''2.''' Set the [[RPC_HELP_TRPCBroker_Connected|Connected]] property to true; this attempts a connection to the VistA M Server: | ||
+ | |||
+ | // Set the Connected property to True, to connect. | ||
+ | RPCBPropSet(RPCBroker, "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. | ||
+ | RPCBPropGet(RPCBroker, "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 [[RPC_HELP_DLL_ExportFN_RPCBCreateContext|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 = RPCBCreateContext(RPCBroker, "XWB EGCHO"); | ||
+ | return result; |
Latest revision as of 16:24, 8 July 2015
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. RPCBPropSet(RPCBroker,"Server", "BROKERSERVER"); RPCBPropSet(RPCBroker, "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. RPCBPropSet(RPCBroker, "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. RPCBPropGet(RPCBroker, "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 = RPCBCreateContext(RPCBroker, "XWB EGCHO"); return result;