02-19-2008 01:56 PM
02-19-2008 02:14 PM - edited 02-19-2008 02:14 PM
A few things you say don't quite make a lot of sense.
TCP is a connection based protocol and the connection is setup with a threeway handshake and closed mutually. If the state is "close_wait", it means that one side sent a FIN packet and considers the connections closed.
Do a google search for "TCPstate diagram" and you should get a better understanding. There is no way to go back to data transfer once the connection is in close-wait state.
For a crude watchdog, you might cosider a connectionless protcol such as UDP.
hspec wrote:
When my software is re-started it trys to link with the lowest available port connection number (which is in the CLOSE_WAIT state) and communication is not possible.
02-19-2008 04:54 PM
The client software which resides on the UUT is closing the connection which puts the connection into the "close_wait" state. The client then creates a new connection (on the server fixed port) and waits 10 seconds before closing it and trying again. Therefore when my labview application is started again there can be many close_wait connections as well as one "established" connection. My problem is that my LV app (the server) tries to link with the lowest connection port number which is in "closed_wait" state. It can take a very long time before we sync back up, because windows does not dispose of the close_wait connections very quickly, and it seems to take labview 4 or 5 seconds to get a connection ID when linking. I would like a method to determine the state of the connection so that I can quickly get to the "established" connection.
I guess another good question would be "why does labview attempt to link with connections that are in close_wait state"
If this is still not clear, let me know and I will try again. The code is way to big for me to send....
Thanks,
Howard
02-19-2008 05:20 PM
hspec wrote:
I guess another good question would be "why does labview attempt to link with connections that are in close_wait state"
02-20-2008 07:42 AM
02-20-2008 11:28 AM
Can you show us some code? How do yo create the listener? How do you close the connection when the program exits?
Are there uninitialized shift register? Any unwired output tunnels that use default?
I don't think LabVIEW has much control about lowlevel TCP/IP details, it just calls system services. Something just does not sound right.
02-20-2008 04:03 PM
02-20-2008 04:10 PM
This might be the problem. I would no re-use any IDs between runs.
hspec wrote:
I then re-use the same listener ID when the power is turned back on.
02-20-2008 04:23 PM
02-21-2008 07:34 AM
Matthew,
The client is C code running on an Avionics box we are developing. I'm not sure how it creates or closes the connection, but I can certainly see what it is doing via the dos "netstat" command.
Yes, the TCP communications between my server and the UUT client are working perfectly under normal conditions. I am able to re-use the Listerner ID. The problem occurs when my code (server) is not running, and the power is on to the Avionics box (client). The client opens, then closes new connections every ten seconds if it does not get the "heartbeat" from the server. The heartbeat is in the form of a simple IDN? query from my code. Windows does not dispose of the closed connections very quickly, so when my code is re-started, there can be many existing connections in the "close_wait" state. My labview code then tries to connect to each of the connections that are in the "close_wait" state, instead of finding the one connection that is "established". This can prevent the client and server from ever re-synchronizing.
My reason for submitting this post was to find out if there is any way to quickly determine the state of the connection, so that I could get to the established connection quickly and re-establish communications. It seems strange that the "TCP Wait on Listener.vi" provides a good connection ID to a port connection that is in the close_wait state. I have checked, and there is no error or warning coming from this vi either.
You mentioned that the example (which is what I originally based my code on) would connect but time out. I just checked my code, and I currently masking the timeout error. I will have a look at this and check if a timeout error is occuring.
Thanks
Howard