O'Reilly logo

Mastering Perl/Tk by Nancy Walsh, Stephen Lidie

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 19. Interprocess Communicationwith Pipes and Sockets

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required