Version 83 of Inventory of IPC methods

Updated 2008-01-30 14:12:49 by vkvalli

Purpose: to inventory the various options one has, from within Tcl, to perform Inter-Process Communication (IPC).


(internet) sockets: socket, TCL-DP (and dp_RPC for a pure-Tcl substitute), CORBA, Scotty's UDP, RPC, SIMPL, Linda (note that Todd Coram cobbled together a tuple space (Tuplespace) in a few lines of incr Tcl), ... See send below too.

Unix-domain sockets: ceptcl

XML-RPC server/client code [L1 ], tclSOAP/SOAP server/client code [L2 ] [L3 ]

Quite a few extensions have been written for shared-memory IPC.

semaphores: http://www.equi4.com/pub/pp/sorted/net/svipc-2.2.0/Index.html (or perhaps ftp://ftp.tcl.tk/pub/tcl/mirror/ftp.procplace.com/alcatel/extensions/svipc-2.1.1.tar.gz ) which covers semaphores, shared memory, and message queues. lexfiend 2007-12-30: It's definitely not building with modern Tcl's & *nixes, but I'm working on a patch for that. More when it's done.

message queues:

mmap'd files:

FIFO: FIFOs are also known as named pipes on Unix. (The fifo of memchan is however something different.) See [L4 ] for a pointer to a technical article about this method. dislocate is an Expect program which uses FIFOs.

send: Note, comm (Previously at [L5 ] - now a part of tcllib) is a socket-based send. Another alternative is ftp://ftp.procplace.com/pub/tcl/alcatel/extensions/tclipc1-0.tar.gz Yet another is winsend which uses Windows COM to implement send.

threads and shared variables:

DDE and COM are Windows only. Macintosh, of course has Applescript (see also [L6 ]) and TclAE. Also, sh8 is Windows only.

XPA is a messaging system for communication between processes.

file: open, read, gets, puts

Tequila: Uses traces, fileevents and sockets to create distributed arrays, i.e. arrays whose content is shared between several applications and where changes are automatically distributed to them all. It makes use of a central server. It does have the advantage that applications can be built using arrays for data storage, and separated into client/server components with only a few additional lines of code.

The "msg" [L7 ] interface that is used to operate F5 instrumentation at the MMT Observatory [L8 ]. Very similar to Tequila above but operates on global variables. It supports publish, subscribe of values and commands. It includes synchronous, asynchronous and unacknowledged messages. Clients persistently reconnect to servers and reestablish thier subscription states automatically. It works very well and is used to tie dozens of hardware and software control functions at the MMT Observatory together. -- JBR (updated by escargo).

unnamed pipeline [L9 ]: [exec], [open |...], [ bgexec ] from BLT, ...

pseudoterminals (ptys): Expect

DB: ..., Tequila, ...

Passing arguments and return codes back and forth: exec, return

YAMI, PVM, Linda (based on Tuplespaces, aka T-spaces), MPI, ...

Is there no Tcl binding to Spread [L10 ]? Perl, Ruby, PHP, ... all connect to it ... 'Seems like the kind of thing davidw would have encountered ...

Anyone worked with DBUS [L11 ]? Is it Linux-specific?

How about ZeroC's ICE [L12 ]? This ICE (Internet Communications Engine) is distinct from X11's Inter-Client Exchange (ICE) protocol, which is used for IPC by Tk's send.


Have an interest in a protocol or technology you don't see mentioned here? As LV once wrote, "Note that this page is a growing list however. Tcl programmers are a versatile bunch, and new methods of communicating between processes are being implemented all the times. So if you have an idea of doing this sort of thing, but do not see it listed on the page, don't take the fact that it is missing as being a limitation of Tcl, but as a limitation of the minds/memories of the people writing the page <smile>."


RS: A simple file signalling between two processes, that both have write access to the same directory (but could run on different boxes and OSes, like Unix and WinNT), can look like this:

 proc fsignal {cmd name {msg ""}} {
    switch $cmd {
     send {
        set fp [open $name.sig w]
        if [string length $msg] {puts $fp $msg}
        close $fp
     }
     wait {
        while 1 {
            if [file exists $name.sig] {
                set fp [open $name.sig]
                set msg [read $fp]
                close $fp
                file delete $name.sig
                break
            } else {after 100}
        }
     }
    }
    set msg ;# return the message from sender in both cases
 }
 # process 1: (when conditions are ripe)
 fsignal send Go 42

 # process 2: (before the real action)
 set Magic [fsignal wait Go]

See also filewait for a related scriptlet.


TV Bear in mind, for those who don't already do, that there are a few basic mechanisms on the os-es and machines I'm aware of, of which signals, sockets (of the local and inet kind), and shared memory are the main ones. Most of the others, including many packages, don't add anything at all or much to the fundamental capacities of these mechanisms in essence, so many limitations and shortcomings of a lot of the parallel programming aids or simulations simply run into the problems and limitations of these facilities, which are on unix, linux, windows, and probably (though there I didn't program them myself), and probably on some of the less well known os-es, too.

To begin with, there is hardly formatting involved in the basics, except essential flow control, there is always overhead for copying data around except in few extreme cases, already in the basic library use, there is no or not much support for actual parallel machine concepts, except that ethernet and maybe some others can be made to broadcast over standard enough socket interface, and generally there is bad or absent exact definition of the operation of the basic library functions, for instance with the important aspect of flow control. Which is the direct and only reason a lot of things fuck up or don't work right over various versions, brands and programmers on the internet. In java for instance. In many printer spoolers, for instance.

Not to mention what this does to performance, a concept a modern university informaticist couldn't even spell out let alone specify, measure right and interpret with some engineering sense to begin with, let alone be able to incorporate in a design, let along in an important language definition.

A lot of interfaces and languages serve no purpose one can optimize much or say something positivily discriminating about because its just a style someone likes, or something their mothers don't recognize, or maybe a certain concept applied consistently.

Some things in tcl, such as the copying of data over sockets are quite optimizable and well designed and for a scripting language highly optimimal in certain sense.

(oct 14 03) I did pcom years ago, which can be used for for instance remote command execution, see examples down the page, and remote execution using tcl and Pcom.


M&M's BOOK Effective Tcl - Writing Better Programs in Tcl and Tk examples no longer appear to be available on-line at the publishers. There is a version available at http://sf.net/projects/efftcl .


AM Here is another shot at interacting processes: Distributing a series of tasks


vkvalli A simple chat server and chat client library can be used for inter process communication. There are quite a few chat server and client implementations in this wiki.

It seems to be suitable candidate for simple coordination among processes with messages.But generally people miss it when they look for IPC mechanisms.


See also: