<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to TCP/IP Connection monitoring based on Network 3.5.7.0 Library</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/d24dd8f315/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/d24dd8f315/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/d24dd8f315/</id><updated>2020-09-18T06:59:13.911000Z</updated><subtitle>Recent posts to TCP/IP Connection monitoring based on Network 3.5.7.0 Library</subtitle><entry><title>TCP/IP Connection monitoring based on Network 3.5.7.0 Library</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/d24dd8f315/?limit=25#10fb" rel="alternate"/><published>2020-09-18T06:59:13.911000Z</published><updated>2020-09-18T06:59:13.911000Z</updated><author><name>nothinrandom</name><uri>https://forge.codesys.com/u/nothinrandom/</uri></author><id>https://forge.codesys.com5dbaf257f698dc523836397bb3cad1a0480ac705</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Probably the easiest approach to this is to implement a heartbeat.  &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Server sends client a dummy message (e.g. "HI") every X seconds to keep connection alive (when you are not regularly sending data to client).&lt;/li&gt;
&lt;li&gt;Client also sends server a dummy message (e.g. "HI") every X seconds to keep connection alive (when you are not regularly sending data to server).&lt;/li&gt;
&lt;li&gt;If either side does not receive this dummy message within Y intervals of X seconds, then close connection.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In each client/server function block, have a boolean input called &lt;strong&gt;hearbeat_check&lt;/strong&gt; from an external timer TON that runs every X+1 seconds... or have a dedicated TON for each function block, but that would be a waste of space.  Anyway, for each function block have two bytes: one called &lt;strong&gt;current&lt;/strong&gt; and the other called &lt;strong&gt;missed_heartbeat&lt;/strong&gt;.  This variable &lt;strong&gt;current&lt;/strong&gt; is set to &lt;strong&gt;1&lt;/strong&gt; if TCP receive buffer has new message.  On the rising edge of &lt;strong&gt;hearbeat_check&lt;/strong&gt;, increment &lt;strong&gt;missed_heartbeat&lt;/strong&gt; if &lt;strong&gt;current&lt;/strong&gt; is equal to &lt;strong&gt;0&lt;/strong&gt;.  Else, reset &lt;strong&gt;missed_heartbeat&lt;/strong&gt; to &lt;strong&gt;0&lt;/strong&gt;.  If &lt;strong&gt;missed_heartbeat&lt;/strong&gt; exceeds some Y value, then close connection.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>TCP/IP Connection monitoring based on Network 3.5.7.0 Library</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/d24dd8f315/?limit=25#ebf7" rel="alternate"/><published>2020-09-04T10:33:38.541000Z</published><updated>2020-09-04T10:33:38.541000Z</updated><author><name>baldeep</name><uri>https://forge.codesys.com/u/baldeep/</uri></author><id>https://forge.codesys.comf7ed25c3180b6555f5809daa3254bf40c407f79c</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello forum,&lt;br/&gt;
i am using a Raspberry Pi (with Codesys 3.5.16.0) as a TCP IP server and almost 80 Raspberry Pi (with Codesys 3.5.16.0) as TCP IP clients. I make an Array of 80 NBS.Connections and let the clients make connections. The server allocates one element of the aforesaid Array randomly. The whole communication is working.&lt;/p&gt;
&lt;p&gt;i have following questions:&lt;br/&gt;
1. The client makes connection then on server side the Server/NBS.connection.Active[x] goes true but it stays true even if the client goes physically offline. Is it so or i made an error? right now i send the timestamp from client to server and as long as it is changing, i know the connection is ok, else i reconnect. Is there any elegent way to solve this.&lt;br/&gt;
2. Can i decide from server side that Server/NBS.connection.Active[x] is only for Client IP xxx.xxx.xxx.xxx&lt;br/&gt;
3. How can i decide from client side that the server Offline is?&lt;/p&gt;
&lt;p&gt;any help is appreciated!&lt;br/&gt;
Thanks in advance&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>