LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP_DISCONNECT

To anyone who can help,
 
I am writing a CVI8.0 program that connects to several TCP servers, receiving data from each of them.  The servers send data every 10 seconds or so, and I am succesfully receiving the data through the TCP_DATAREADY call-back, and handling it through the appropriate 'handle' that was opened with the server.
 
However, if a server disconnects for some reason, I have not been able to work out how to use the TCP_DISCONNECT call-back to show which one has disconnected, and therefore take the appropriate action to re-connect just that server.
 
Please can any give me a clue as how to work out which server has disconnected using the TCP_DISCONNECT call-back?
 
Many thanks in anticipation of yor help,
 
Allen Cherry
0 Kudos
Message 1 of 2
(2,977 Views)
Hi Allen.

If all you need is the IP address of the server which has disconnected, you can use the handle parameter in the callback to obtain it, using GetTCPPeerAddr().

One way to track multiple conversations is to set up an array of structs, with each member holding server-specific information, and pass the appropriate array index (cast to void *) in the ConnectToTCPServer() call. Then the callbackData parameter of each message you receive from that server will hold the index corresponding to the server's data (also cast to void *).

Good luck,
Colin.


0 Kudos
Message 2 of 2
(2,962 Views)