Socket code examples
Kevin Brooks
kevin.brooks at motorola.com
Tue Jun 17 21:55:58 EDT 2008
For some reason I have not been able to get inter-application data passing
using sockets to work. Is there sample code that I can see? My needs are
as follows.
I wrote a large Mac Rev app that does a lot of media playing and
manipulation. A work colleague has written a Mac application in java around
some data processing algorithms of his. The project is to have his app
control my app. Since my app can take keyboard entry to control its media
and windows, our idea was to establish a socket connection between the two
apps, with his app sending chars to mine, and my app would interpret them
like keydown events. However, due to geographic distance, we need to do our
respective development separately, sharing apps via email.
All I want to do is create a test app that opens a socket on a specified
port and listens (reads) that port, displaying what it reads in a field.
Once successful, I'll transfer that working code to my main media app. I
want to make a second test app that opens a port and sends data to the first
test app. Pretty simple. A shortened version of previous assumptions
(according to the documentation) are:
The Reading App:
put "127.0.0.1:50101" into lsocketID
accept connections on port lsocketID with message "connectionmade"
Where connectionmade will call itself every xxx millisecs
read from socket lsocketID for 5 with message "displayreaddata"
The Sending App:
put "127.0.0.1:50101" into lsocketID
open socket to lsocketID with message "connectionmade"
And once the connection is made, a btn script will trigger data to be sent
from a field:
put fld "datafld" into sendingdata
write sendingdata to socket lsocketID with message "writeconfirm"
This is how I understood it works, but clearly I'm wrong. I got things to
sort of work using the "datagram" form of the accept and open statements,
but not well. Some sample code would be much appreciated.
Thanks,
Kevin
More information about the use-livecode
mailing list