IPCsocket inter-app communication

In my quest to eliminate lag from my application, which runs on a timer consistently getting api information every 15 seconds… I tried to implement the use of a thread, which seemed to slow things down more, at the very least however made no improvement.

So now I’ve moved to using the IPCsocket and I’m wondering… If my ‘helper app’ needs to calculate data to fill an array that then fills a listbox…
how would i format the array such that i could send it and set it equal to

listbox1.cell(-1,-1) = stringArray()

?

Have a look at JSONItem. http://documentation.xojo.com/index.php/JSONItem in particular the Array methods.

Listbox1.Cell(-1,-1) takes a tab delimited stirng

ListBox.Cell

Make a string using join with the array and tabs (chr(9)) as the separator.

Listbox1.Cell(-1,-1) = Join(stringArray,chr(9))

Turns out it was really simple. I took the IPCsocket example application and made 2 copies, I edited the one to populate a listbox with 3 columns and values on the rows etc., etc.,

So basically what I did was I had a button that sent the listbox info across the IPCsocket connection

CommSocket.Write(listbox1.cell(-1,-1))

and then in the DataAvailable event handler for the commsocket on the OTHER application I put

Listbox1.cell(-1,-1) = (me.ReadAll)

The best part about it… is I didn’t even have to worry about column counts or anything… it carried all that data with it… I was expecting an out of bounds error, but nope, thankfully it just worked, and dont we all love it when things just work :slight_smile:

Such a simple solution, to what i thought was a hard problem. Once i get this working as a replacement for threads, I’d like to share all the info with everyone, Maybe it will help some novices or intermediates.

This will work fine for small amounts of data, but what if the dataavailable event fire’s multiple times for a block of data?

I’d like to suggest the following changes.

This

CommSocket.Write(listbox1.cell(-1,-1))

becomes

CommSocket.Write(listbox1.cell(-1,-1)) + chrb(26)

ChrB(26) is an end of file marker.

This

Listbox1.cell(-1,-1) = (me.ReadAll)

becomes

If InstrB(0, Me.Lookahead, ChrB(26)) = 0 Then Return Listbox1.cell(-1,-1) = (me.ReadAll)
Which will leave the data in the buffer until the End Of File marker is complete.

[quote=125169:@Wayne Golding]

If InstrB(0, Me.Lookahead, ChrB(26)) = 0 Then Return Listbox1.cell(-1,-1) = (me.ReadAll)
Which will leave the data in the buffer until the End Of File marker is complete.[/quote]

so what happens if it fires again before eof ?

Nevermind its late… didn’t read your answer, sorry. Thanks for your help!