Updated 2015-12-21 21:18:41 by pooryorick

Message passing refers to the messages that information systems pass among themselves in a concurrent system, achieving thereby some kind of distributed computation. Message passing systems use some form of inter-process communication provided by the platform.

Further Reading  edit

Architectural Styles and the Design of Network-based Software Architectures, Roy Thomas Fielding, 2000
A great overview of approaches to software design based on message passing. It proposes REST as another approach.

Description  edit

In message-passing systems, one system makes a request, and another provides a response. The requestor is called the client, and the responder is called theer server. These roles exists even in peer-to-peer systems, where the participants take on one role or the other for the duration of the conversation.

Tools  edit

irc
vkvalli: A simple chat server and chat client library can be used for message passing . 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.
A Thread-Safe Message Queue
Spread
Provides a high-performance messaging service that is resilient to faults across external or internal networks.

Applications  edit

RPC
Conversations dressed up as procedures.
remote interpreter
In the Tcl world, communicating with remote interpreters is a particularly effective and satisfying activity.

Example: File Signaling Between Two Processes  edit

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.