Sending arrays through sockets, from different platforms and different system languages

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
trevix
Posts: 441
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Sending arrays through sockets, from different platforms and different system languages

Post by trevix » Tue Jul 24, 2018 5:11 pm

I went back to an App of mine, Tcal, started with LC 5.5, and developed now with LC 8.1.10.

The App is made of a standalone server and several standalone clients.
Each clients writes to the server and the server respond to each clients.
Clients can be OSX or Windows. The same for the server. Each one can also run with different System settings (different part of the globe) with accented chars, etc.

It was working fine, but now I decided to change the the data format that is transmitted through sockets, going from "|" delimited text to multi-key arrays (like tArray["some"]["other"]), because of much easier internal handling.

I need suggestions on how is better to pack the data that get sent trough sockets.
I use to handle the different platforms simply using a "IsoToMac" and "MacToIso" (everything arrived as Mac formatted text and then eventually converted) but now with array, things get a little more complex.
Because of the use of array, I need ArrayEncode and ArrayDecode before transmission and on receive.
(I may also have to "Base64Encode" and "Base64Decode" the data, to ensure safety).
With text I could just Base64Encode(IsoToMac(TheData)) everything before transmission.
With Array, while I can ArrayEncode and Base64Encode each array on the transmit script, I must decide where in my scripts to do the IsoToMac(each key and content of the array)

Any suggestion on how to deal with these problems? Speed problems?
I tried to read about Unicode (http://livecode.byu.edu/unicode/unicodeInRev.php) but i simply don't grasp it (sigh)
Trevix
Trevix

trevix
Posts: 441
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: Sending arrays through sockets, from different platforms and different system languages

Post by trevix » Tue Jul 24, 2018 6:21 pm

I just found out that I cannot do this (on windows it does not work):

Code: Select all

 put ArrayEncode(tArray,"7.0") into tText
put IsoToMac(tText) into tText
put MacToIso(tText) into tText
  put ArrayDecode(tText) into tFinalArray
So i guess there is not other mean that go with a repeat for each key and each content
Trevix

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5104
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Sending arrays through sockets, from different platforms and different system languages

Post by jacque » Wed Jul 25, 2018 5:16 pm

ArrayEncode changes the text to binary. Do the ISO conversion first, then ArrayEncode it. Reverse the process to decode.

But LC now handles unicode automatically so you shouldn't need to use ISO conversions at all.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”