The term interprocess communication describes a scenario in which two or more processes talk to one another. The processes may reside on the same computer or they may be on separate computers connected via a network. In Unix, there are several IPC mechanisms: pipes, semaphores, signals, shared memory, and sockets, to name a few. All are useful for local communication, but sockets are typically used for communication over a network.
The problem with reading and writing a network socket is that an I/O operation often takes a considerable amount of time to complete, which, as described in Chapter 15, might block the flow of Tk events. Your program then stalls, and the user becomes unhappy. But with care, it’s possible to mix network programming with Perl/Tk and still maintain lively event processing.
In this chapter, we’ll write some Perl/Tk network programs using pipes and sockets. In Chapter 20, we’ll cover more examples using an IPC mechanism unique to Tk, the send command.
The first example in this chapter is a simple TCP/IP media change client/server, just to become familiar with the basic mechanisms. These programs help automate daily tape backups on a Linux computer. The client sends an operator message to a central machine, requesting a tape change, and the server posts the message in a Perl/Tk window and returns the operator’s response.
Later, we’ll develop a Tk user interface that updates flat files ...