Bill:

I agree sockets is the way go for communication between apps. AppleScript is 
great but can be frustrating until you get the hang of it.

The recipe for setting up socket communication is briefly:

. write a small unix shell script which your LC app installs [one caveat: the 
client must allow your app to install an executable script into /usr/local/bin]
this app simply collects the input parameters, opens a socket with 
“nc <local ip of your mac>  <port#>” 
and send the the params to the socket

The 3rd part app calls this script with a shell command “/usr/local/bin 
myScript param1 param2 “ etc [multi world parameters in quotes to form a single 
string]

. on the LC side, your app on launch (or whenever) opens a socket with
“accept connections on port <port#> with message “clientConnected”

Then whenever the shell script is called, your “clientConnected” handler will 
be invoked. 

You read the message sent with"read from socket …” and parse the message sent 
and process it.
You can also write back to the shell with "write to socket…” if you want, for 
the 3rd party to use a reply directly (or of course send data via item files)

Works great! I actually use it to send a filename as first parameter, where the 
file is an LC script, and the processing is simply ”do script <filename>”, 
having put any extra parameters into local variables. This way I can open up 
the whole of the LC app to remote control. You can provide the client with 
prepared script files for particular jobs, without have to rewrite your LC app 
when you want to open up access to a feature. Do script could open up a 
security risk, but you could only accept encrypted files if this is a worry.

As opposed to using AppleScript, this approach will also work if the client 
runs your LC app on a Linux box.

Question for the forum: how to make this work on a Windows box — is there an nc 
equivalent in a command shell for Windows? (I am not a Windows user but some of 
my clients are) 



Neville Smythe



_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to