Checking state of IP connection
MorgoZ
Posts: 116
Hello,
i would like to know the best way to detect if an IP connection is open or closed with Netlinx. I mean:
At one section of code, i use the IP_CLIENT_OPEN keyword to open an IP connection at a specific local port of the master.
At other section of code, i use the IP_CLIENT_CLOSE keyword to close that IP connection.
And at a third section of code i need to know in which state are the IP connection, if it is open or closed.
Do you know any other way to check it, apart of using a boolean variable? Or is it the only available method?
Thanks for your help!
i would like to know the best way to detect if an IP connection is open or closed with Netlinx. I mean:
At one section of code, i use the IP_CLIENT_OPEN keyword to open an IP connection at a specific local port of the master.
At other section of code, i use the IP_CLIENT_CLOSE keyword to close that IP connection.
And at a third section of code i need to know in which state are the IP connection, if it is open or closed.
Do you know any other way to check it, apart of using a boolean variable? Or is it the only available method?
Thanks for your help!
0
Comments
0 - offline
2- IP Client/Server Open in progress
1 - Connected
While in state 2, no additional Open should be done to that port.
If the IP connect failed (~ 1 minute timeout from TCP handling) you'll get an ONERROR event. At this point, reset the variable to state 0.
I actually take it a step further and create a few other states like disable so depending on what type of onerror return I get I'll disable as opposed to auto re-connect. The TX & RX are just in case I want blinking lights for feedback, often I won't.
Pending is for the time between IP_CLIENT_OPEN and the online event triggering just to prevent other things from happening like the auto re-connect.
Device ready is for certain devices that reguire log in or other procedures before they'll respond to additional commands.