Socket Tutorial Guidelines [was: thank you notes]

Dar Scott dsc at swcp.com
Mon Nov 25 18:13:01 EST 2002


On Monday, November 25, 2002, at 02:49 PM, Rob Cozens wrote:

> Basically, I would like to see the ins & outs and dos & don'ts of 
> establishing interprocess communication via sockets, eg: how do I 
> establish communication & exchange data between two or more Rev 
> standalones.

Personally, I like TCP/IP for IPC.

It is interesting that you brought this up.  (No, folks, Rob and Dar are 
not the same person; I don't think I have even met Rob outside this 
list.)  I think it would be good to encourage discussion on what Rev-Rev 
IPC might be like, should it grow beyond a few ad hoc methods.

>
> Perhaps this is a good time to ask for confirmation of what I think I 
> know:
>
> I have selected socket communication as the preferred approach to 
> interapplication communication because it is the only approach I know 
> of that works on all platforms, and over the Internet as well. 
> Obviously, scripting Apple event handlers does one little good when 
> it's time to port to Unix/Windows.  Am I losing any significant timing 
> and/or data passing capacity advantages of platform-specific avenues of 
> interprocess communication?

It depends on what you think as significant.  Figure on a couple ms on 
the same lan or same computer.

For communication on the same computer or the same lan, UDP will work 
fine.  I use it with some robustness added over the Internet.  Messages 
will have to be under about 64 K.  Over a WAN or Internet I would keep 
the datagram small (under 1000 char).  For larger messages (over 64K 
local or over about 1000 remote) you should TCP.  That will have a time 
hit in connecting, though.  If you are streaming, use UDP or keep a TCP 
link connected.

I reported on the improve list a "write dalliance" bug that can affect 
performance on OS X.  It does not apply if you use callbacks, which I 
encourage anyway.

I have been plagued with a "same computer" or "very, very slow computer" 
problem on Windows that prevented use of TCP; the notification of the 
open success came before the engine was ready to receive it.  This has 
been fixed with MC 2.5A6, so this should be OK on Revolution 2.0.

> In other words, is there any intrinsic reason for using Apple events on 
> Macs and  their equivalent on Windows vs using sockets on both?

There might be if your need is immediate for OS X.  It has been 
mentioned to me that UDP IPC experiments on OS X show a delay in message 
transfer if the recipient does not have the active window.  I have not 
looked into this, but you may want to run the experiment before a final 
decision.  (I don't know if this is the same as the "write dalliance" 
bug.)  I hope this gets fixed (or is already fixed), but I'm up to my 
neck in Windows alligators, so I don't know when I'll get a chance to 
look at it myself.

There are (were?) some minor differences between OS X and Windows that 
will have to be addressed.  If a connection is refused, you get a 
socketError on Windows but a socketClosed on OS X, for example.  The 
timeouts for open are host dependent.

Summary:  Yes!  TCP/IP for Revolution IPC!

Dar Scott






More information about the Use-livecode mailing list