LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

DataSocket connections

when i have two connections to the DataSocket server how can i know that one of them was disconected ?
0 Kudos
Message 1 of 4
(3,380 Views)
When you create each of the connections you should be specifying a unique connection handle for each and a callback function to be called (they can actually use the same callback function) when you call DS_Open for each. Your callback function will have the form:

static void CVICALLBACK OurDSCallback (DSHandle dsHandle, int event,
void *callbackData);

and since this callback function will be called for all events that happen to the connection and will specify which connection fired the event in the dsHandle parameter you will know exactly which connection caused the "event" to happen that made the callback function execute. The event of interest in this case is DS_EVENT_STATUSUPDATED, and to check what the actual status is for this instance of the callback fu
nctions execution you can call the DS_GetStatus function to see if the connection is now in a DSConst_Unconnected state.

To view further information about this, look at the CVI function help for DS_Open and DS_GetStatus as well as the MultiOPCClient.prj example in the cvi\samples\datasocket\multiopcclient directory for an example that shows how to use one callback for multiple connections (note this is connecting to an opc server and not a datasocket server).

Jason F.
Applications Engineer
National Instruments
www.ni.com/ask
0 Kudos
Message 2 of 4
(3,380 Views)
i have the callback like in the examples and like u discribe, but when one of the connectios disconnect from the server there is no DS_EVENT_STATUSUPDATED at all!!!
0 Kudos
Message 3 of 4
(3,380 Views)
Does the MultiOpcClient project display this behavior as well on your particular machine? Because if this works really it should work in all cases, even when connecting to a DataSocket server, because it is the COM Automation server (the Datasocket functions you use in your app are provided by a COM Automation server implemented in the nids.dll file) for the client process in your application that is checking the status, and will do so regardless of what kind of connection it has. If this example works, there must be something in your app that you are overlooking.

Jason F.
Applications Engineer
National Instruments
www.ni.com/ask
0 Kudos
Message 4 of 4
(3,380 Views)