03-24-2016 07:09 AM
03-25-2016 01:08 AM
Hi Crossrulz,
1. It runs properly now.
2. I set the timeout of the 2 TCP Read 50ms, but Stop Button still did not work. And if I press Stop button once, then start the program again, the VI is extremely slow. I have to close the VI then open again to make it work.
3. If I close the client first, I always get an error 1 from the TCP read. How to fix it?
03-25-2016 06:23 AM
@Bestest_boy wrote:3. If I close the client first, I always get an error 1 from the TCP read. How to fix it?
A TCP connection is a two way street. If the client closes the connection, then the server will get the error.
What you really need to do is make your TCP loop a state machine. Have a state for making a connection, waiting for a message, sending the data, and closing your connection. The idea here is that you start by setting up a connection. Once a connection is established, you go to the wait state. If you get a connection error in the wait state, you should close your connection reference and then go back to making a connection.
04-15-2016 03:58 AM
Hi Crossrulz,
I made a state machine for TCP loop already and it worked. However I caught a problem with the Stop signal.
- My Client is fixed and I cannot change the way it gets and sends data.
- In my VI server, Stop button is checked to go to Stop state. In the case Stop, I close the TCP connection and stop all the loops. And I got problem here. If the Client close first, the TCP refnum is 0 and this becomes an invalid input for the input of TCP Close Connection. Everything is OK if I close the server first.
Do you have any idea to solve this problem?
Attached is my VI.
04-18-2016 09:19 AM
If the TCP Refnum is consitently changing to 0 on client disconnect, you could monitor the refnum and exit into a shutdown state when that is seen. You can also monitor for error codes 62, 64, 66 which are:
"The system caused the network connection to be aborted", "The network connection is not yet established", and "The network connection was closed by the peer" errors, respectivley.
04-18-2016 09:40 AM
04-18-2016 01:47 PM
@Bestest_boy wrote:
What will I do in the Shut down state? Close connection or something else? But with refnum 0, I cannot use TCP Close Connection.
The same with error codes monitoring. When I get 66, what will I do?
In the shutdown, just use Clear Error to clear error 66. Obviously, if the connection was already closed, you cannot close it again. That is nothing to worry about during the shutdown.