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 eval
ing 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.
Get Mastering Perl/Tk now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.