LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

how can I know wether the handle of TCP connection is still valid?

I have registered a TCP port and a servercallback function. I got the Tcp connection handle when I got EVENT TCP_CONNECT, But if the connection was exceptionally broken, in this case, I would get the Event TCP_DISCONNECT.how can I know wether the handle of TCP connection is still valid?
I appreciate your help!
0 Kudos
Message 1 of 4
(3,305 Views)
A CVI TCP server gets the DISCONNECT event when a connected client disconnects from the TCP conversation, or when some network error breaks the conversation. In both cases, the conversation is termninating and you should ensure that the conversation handle is properly closed. The CVI TCP library supports automatic closing of disconnecting handles as well as explicit (manual) closing of the handles. See the documentation for the SetTCPDisconnectMode function. By default, the disconnect mode is automatic and so you do not have to close the handle explicitly.
0 Kudos
Message 2 of 4
(3,297 Views)
I am sorry. There is something incorrect in my questiont.The right one should be,
"I have registered a TCP port and a servercallback function. I got the Tcp connection handle when I got EVENT TCP_CONNECT, But if the connection was exceptionally broken,like in this case of suddenly power off, I wouldn't get the Event TCP_DISCONNECT.How can I know wether the handle of TCP connection is not valid any more?
I appreciate your help! "
I found, in the case of suddenly power off, I cann't get TCP_DISCONNECT.
Thank you.
0 Kudos
Message 3 of 4
(3,287 Views)
Hello,

I found an interesting post on a previous thread. This customer created code that tries to auto-connect to the server. It's almost like it constantly polls to see if there is a live connection, in order to get around the problem of not getting the disconnect event.

Take a look at the following thread: http://forums.ni.com/ni/board/message?board.id=180&message.id=12436&requireLogin=False

Hope that helps.
Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 4 of 4
(3,228 Views)