News:

  • September 29, 2026, 04:03:27 PM

Login with username, password and session length

Author Topic: How the success,fail, active flags work in TCP  (Read 6488 times)

Bobby

  • Sr. Member
  • ****
  • Posts: 60
How the success,fail, active flags work in TCP
« on: February 22, 2019, 06:39:57 PM »
Hi all,

I am having problems at a client's site using TCP and am hoping to get a more technical understanding of how the PLC actually knows a TCPOPEN, STREAMOUT and such know they are success or fail.

Problem currently is the PLC flags 'Success' on both the port open and on a STREAMOUT to his software, but he is telling me it isn't connected....it then seems to start working after a 3-4 messages but those are all lost.

I use the same code from my end on every project and having been using it for years. So I assume it is from his end but I just want to give a more educated explanation of what I see on my end.

Thanks!

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: How the success,fail, active flags work in TCP
« Reply #1 on: February 22, 2019, 08:12:45 PM »
With any Do-more instruction that uses Success/Error, both flags get cleared as soon as the input leg is turned on, and the Success or Error result gets turned on when the box is complete. If you invoke STREAMOUT on a connection that is closed, it will immediately error out and set the system error value. From the point that the box is complete, the instruction is no longer involved...just the underlying device.

Since OPENTCP can succeed, and then the connection fail later, you can check the connection status in the client device's structure. If you created a client device named TCP, it automatically creates a structure named $TCP, containing the field .Connected, which will turn off when the connection has been lost. Use this to determine if you need to reopen the connection.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO