Chapter 20. IPC with send
There’s an interprocess communication
mechanism unique to Tk: the send
[1] command. As originally implemented in
Tcl/Tk, send transmits commands (which, in Tcl,
are simply strings) to another Tcl application running on the same
display. The receiving application then executes the commands and
replies with the results. Think of it as an eval
in the context of the receiver, performed automatically by Tcl/Tk.
Perl/Tk provides a send command too, but the
default receiver is a simple stub that rejects all incoming
send requests. Fortunately, we can override that
behavior by writing our own receiver. And we’re not constrained
to merely evaling the incoming data, but can do
whatever we please.
Using send, we can write remote controllers,
client/server applications, parallel programs, and intriguing games.
In this chapter, we’ll see examples of some of these written in
Perl and, in a mind-stretching twist, Tcl.
[1] Currently, send
is not
available on Win32 operating systems. This may change in the
future.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access