stacks interacting over LAN? (newbie)

Alex Tweedly alex at tweedly.net
Tue Nov 30 04:31:05 CST 2004


At 14:34 30/11/2004 +0900, kweto wrote:

>Hello All,
>
>What I have in mind is somehow "connecting" two stacks that are running on
>separate computers over a small LAN so that they interact with each other in
>real time. For example, a student clicks on a button representing the letter
>"A" on her computer's stack and, immediately, another student on a separate
>computer's stack sees that same letter appear as well as hears a
>corresponding sound file.
>
>Now, rather than expecting an entire scripting solution (to which I of
>course would not say "no"!), I'd just like some pointers in the right
>direction. Where in the documentation can I learn more? What sample stacks
>are there that I might tinker with? In the past I've (barely!) managed to
>incorporate SQL functions into separate stacks running on a LAN, but that
>was "simply" to read/write data from/to a common text file. I have no idea,
>however, how to make one stack "aware" of and "reactive" to, for example,
>mouse-events or global variables that are initiated by another stack.
>Sockets? Pipes? Is this so complex that I'd better just give up now??

Sockets.  And no, it's not difficult - don't give up now :-)

Look at "open socket", "read from socket", etc.

Also, you'll want the "accept" command.

something simple like
  - Computer A will "accept" on a socket 7654
           (any number in the high thousands should be generally free)
  - computer B  will "open socket ipaddressOfComputerA:7654"

and then they can use "read from ..  until CR . with callbackfunction"
and "write to ... "
to communicate. Be sure to use the "read from ... with callback" - this 
allows the application to continue running normally, and then calls the 
specified handler when data is available.

I don't know of a sample stack, but I'm sure there will be one somewhere ....
You could look at Bjornke's chat client at 
http://home.wanadoo.nl/mark.sch/software/chatrev.html though there is a bit 
more in there than just the simple sample you really want.

-- Alex.


More information about the use-livecode mailing list