Section B.13. Networking and IPC

B.13. Networking and IPC

If there's a way that programs on your machine can talk with others, Perl can probably do it. This section shows some common ways.

B.13.1. System V IPC

The standard functions for System V IPC (interprocess communication) are all supported by Perl, so you can use message queues, semaphores, and shared memory. An array in Perl isn't stored in a chunk of memory in the same way[*] that an array is stored in C, so shared memory can't share Perl data as is. But there are modules that will translate data, so you can pretend that your Perl data is in shared memory. See the perlfunc manpage and the perlipc module.

[*] It would be a lie to say that a Perl array is stored in "a chunk of memory" at all as it's almost certainly spread among many separate chunks.

B.13.2. Sockets

Perl has full support for TCP/IP sockets, which means that you could write a web server in Perl, or a web browser, Usenet news server or client, finger daemon or client, FTP daemon or client, SMTP or POP or SOAP server or client, or either end of pretty much any other kind of protocol in use on the Internet. You don't need to get into the low-level details because there are modules available for all of the common protocols. For example, you can make a web server or client with the LWP module and one or two lines of additional code.[] The LWP module (a tightly integrated set of modules, which implement nearly everything that happens on the Web) is a great example of high-quality Perl code, if youd like to copy from the best. For other protocols, search for a module with the protocol's name.

[] Though LWP makes it easy to make a "web browser that pulls down a page or image, rendering that to the user is another problem. You can drive an X11 display with Tk or Gtk widgets or use curses to draw on a character terminal. It's all a matter of downloading and installing the right modules from CPAN.

Learning Perl
Learning Perl, 5th Edition
ISBN: 0596520107
EAN: 2147483647
Year: 2003
Pages: 232

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: