NetTalk Central

The Rest Of NetTalk => The Rest - Ask For Help => Topic started by: tglomb on April 22, 2015, 11:06:17 AM

Title: NetSimple - which housekeeping code between connection breakdown and reconnect
Post by: tglomb on April 22, 2015, 11:06:17 AM
Hello,
I need some help or insights for the following situation: with my NetSimple App I connect to a Socket
of a another Software which I have no control of and send some data to them. It works well in general.
From time to time this Connection is closed by their Software, they dont know why. My question is
which kind of housekeeping I must do in between the connection breakdown and my reconnect.
Please have a look at my code (shortened), especially at the ???:
in a timer event I have (the connection is opened in init)..

0{ prop:timer}= 0 
now collectig the objects to send
loop over the objects
  if ThisSender.OpenFlag
    ...
    ThisSender.send()
  else ! when the conn is closed by receiver
    ??? do I need here some housekeeping code or so ???
    ThisSender.AsyncOpenUse= 0                                      ! I use sync mode
    ThisSender.InActiveTimeout= 100000000
    ThisSender.Open( ip, port)
    if ThisSender.OpenFlag
      ...
      ThisSender.send()
    else
      saving remaining objects to send for resending later
      break
    end
  end
end!loop
0{ prop:timer}= 6000

Any hints appreciated.
TIA, Thomas 
Title: Re: NetSimple - which housekeeping code between connection breakdown and reconnect
Post by: Bruce on April 23, 2015, 06:33:14 AM
>> From time to time this Connection is closed by their Software, they dont know why.

that's completely normal network behavior and should be expected.

Typically if you send over a connection that is closed, ErrorTrap will be triggered. So you should use that to trigger a re-open.

However glancing at your approach, it doesn't look terrible. Are you having any problems with it?

cheers
Bruce

Title: Re: NetSimple - which housekeeping code between connection breakdown and reconnect
Post by: tglomb on April 23, 2015, 09:30:28 AM
So far no probs.
I wanted only to be sure that I'll get no probs if I rely only at ThisSender.OpenFlag = false and simply do an Re-Open.. without any Close or Abort before.. I mean some kind of housekeeping before going on.
TIA, Thomas