NetTalk Central

Author Topic: NetSimple - which housekeeping code between connection breakdown and reconnect  (Read 3148 times)

tglomb

  • Jr. Member
  • **
  • Posts: 78
    • View Profile
    • AObit Software
    • Email
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 

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11181
    • View Profile
>> 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


tglomb

  • Jr. Member
  • **
  • Posts: 78
    • View Profile
    • AObit Software
    • Email
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