![]() |
Copas - TCP status and Control - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Copas - TCP status and Control (/showthread.php?tid=5420) |
Copas - TCP status and Control - Diggerz - 17.05.2024 Hi im using an example of Copas and wanted to add some additonal features: 1. Status of connection to object - i guess i can just write to an object at line " alert('[tcp-client] connection ok') " and line " alert('[tcp-client] connection failed (conn): ' .. err) " 2. Object to control TCP connect, reconnect and disconnect - Aside from just disabling and enabling the script is there a method to call functions for connect, reconnect and disconnect from an object while the script is running? 3. Detection of loss of TCP connection and attempt to reconnect - i tried adding a kep alive function that sends a string 'ping' and try to check if it fails to send, however this does not work. I disconnect the ethernet to the end device and the 'ping' message keeps sending and copas/ tcp does not fail or recognise the end device is no longer connected? Code: if not ready then RE: Copas - TCP status and Control - admin - 20.05.2024 Please describe your task in more detail. Most likely this can be done without copas, just with normal sockets and correctly set timeout values. RE: Copas - TCP status and Control - Diggerz - 20.05.2024 (20.05.2024, 07:24)admin Wrote: Please describe your task in more detail. Most likely this can be done without copas, just with normal sockets and correctly set timeout values. Im using copas as the device being connecting to only accepts 1 TCP conenction on 1 port for send and recieve. local UDP server on the LM sends event driven messages via copas TCP conenction which also recieves and updates objects. I'd like to periodically check the connection is still alive and update a status object. The device uses the same port for commisisoning, so i want to add some buttons to a page to disconnect, connect or do a reconnect ( refresh the connection ). So when commisisoning is required we can disconnect, and then reconnect when commisioning is complete. |