Non blocking question

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Pistris
Posts: 148
Joined: Mon Jul 20, 2015 2:40 am

Re: Non blocking question

Post by Pistris » Wed Feb 27, 2019 9:05 pm

after a whole night of testing I just realized this is normal behavior

basically if the LC engine is doing other stuff it will lump all data together until it has time to call the handler again.

so I have to add a sort of flag to the beginning and end of the data strings so I can process it later

Anyways at least I understand what is non blocking now

as a side note, i ran a test that had an interesting result
I wrote a little piece of code that cycled 2000 times and transmitted a string of 100 characters

on the other machine i wrote some code to receive de data and put it on a field,
the code below get the data and put it in the field

on messagereceivedout pSocket, pMsg
global varMessageline
put pMsg into line varMessageline of field incomingt
put varMessageline + 1 into varMessageline
read from socket pSocket with message "messagereceivedout"
end messagereceivedout

the result was that on the field the 1st line was the 100 characters
and the second line was the remaining 199900

so that means that in the time that live code took to put the information on the field , all the
other data arrived and was put together in pMsg

if I add a "wait 50 millisecond" on the loop that sends the data then it gives plenty of time
to the machine that receives the data to populate the field line by line

the end result is the what I said at the top, I need to add a delimiter to the data streams so I can process
them later.

this is all great news actually, cause it means I don't have to fear data not being read

Tonight am gonna test transferring a big text file "the Bible" from multiple instances at the same time
and put them in text files on the receiving end and then comparing to see if all data is intact
am gonna host the receiving end on a virtual server on the other coast and see the reliability
but so far am very happy with live code and the things it can do

Happy live coding

Klaus
Posts: 14196
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Non blocking question

Post by Klaus » Wed Feb 27, 2019 9:35 pm

Hi pistris,

you can also manage the amount of date you want to accept from a socket for one read:
...
read from socket tSox for 100
...
Will read 100 characters from that socket, maybe that will help you, too.

Some hint for speed:

Code: Select all

on messagereceivedout pSocket, pMsg
  global varMessageline
  
  ## Get used to put QUOTES around names of objects (and strings in general)
  put pMsg into line varMessageline of field "incomingt"
  
  ## Save some typing, too :-)
  add 1 to varMessageline
  read from socket pSocket with message "messagereceivedout"
end messagereceivedout
This will cause the engine to count all lines of that field in every run, save some time and maybe just:

Code: Select all

on messagereceivedout pSocket, pMsg
  put CR & pMsg AFTER field "incomingt"
  read from socket pSocket with message "messagereceivedout"
end messagereceivedout
Best

Klaus

Pistris
Posts: 148
Joined: Mon Jul 20, 2015 2:40 am

Re: Non blocking question

Post by Pistris » Wed Feb 27, 2019 10:03 pm

Lol

add 1 to varMessageline

I keep trying to stuff old school :)

I will try your recommendations tonight and be back with results

thanks Klaus

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7392
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Non blocking question

Post by jacque » Thu Feb 28, 2019 6:08 pm

bogs wrote:
Wed Feb 27, 2019 8:50 pm
:oops: :oops: :oops:
(going out to bury my head in a snow bank)
:oops: :oops: :oops:
Don't feel bad, you are not an anomaly. :-)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Pistris
Posts: 148
Joined: Mon Jul 20, 2015 2:40 am

Re: Non blocking question

Post by Pistris » Thu Feb 28, 2019 7:23 pm

All works like a charm

Thanks Klaus for the tip ( read from socket tSox for 100 )

also using ( read from socket tSox until return ) simplifies things


thank you all

Post Reply