📄 appb_13.htm
字号:
<html><head><title>Networking and IPC (Learning Perl, 3rd Edition)</title><link rel="stylesheet" type="text/css" href="../style/style1.css" /><meta name="DC.Creator" content="Randal L. Schwartz and Tom Phoenix" /><meta name="DC.Format" content="text/xml" scheme="MIME" /><meta name="DC.Language" content="en-US" /><meta name="DC.Publisher" content="O'Reilly & Associates, Inc." /><meta name="DC.Source" scheme="ISBN" content="0596001320L" /><meta name="DC.Subject.Keyword" content="stuff" /><meta name="DC.Title" content="Learning Perl, 3rd Edition" /><meta name="DC.Type" content="Text.Monograph" /></head><body bgcolor="#ffffff"><img alt="Book Home" border="0" src="gifs/smbanner.gif" usemap="#banner-map" /><map name="banner-map"><area shape="rect" coords="1,-2,616,66" href="index.htm" alt="Learning Perl, 3rd Edition" /><area shape="rect" coords="629,-11,726,25" href="jobjects/fsearch.htm" alt="Search this book" /></map><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="appb_12.htm"><img alt="Previous" border="0" src="../gifs/txtpreva.gif" /></a></td><td align="center" valign="top" width="228"><a href="index.htm"></a></td><td align="right" valign="top" width="228"><a href="appb_14.htm"><img alt="Next" border="0" src="../gifs/txtnexta.gif" /></a></td></tr></table></div><h2 class="sect1">B.13. Networking and IPC</h2><p>If <a name="INDEX-1256" /><a name="INDEX-1257" />there's a way thatprograms on your machine can talk with others, Perl can probably doit. This section shows some common ways.</p><a name="lperl3-APP-B-SECT-13.1" /><div class="sect2"><h3 class="sect2">B.13.1. System V IPC</h3><p>The standard functions for <a name="INDEX-1258" /> <a name="INDEX-1259" />System V IPC (interprocesscommunication) are all supported by Perl, so you can use messagequeues, semaphores, and shared memory. Of course, an array in Perlisn't stored in a chunk of memory in the same way<a href="#FOOTNOTE-409">[409]</a> that an array is stored in C, so shared memorycan't share Perl data as-is. But there are modules that willtranslate data, so that you can pretend that your Perl data is inshared memory. See the<em class="emphasis">perlfunc</em><a name="INDEX-1260" />manpage and the<em class="emphasis">perlipc</em><a name="INDEX-1261" /> module.</p><blockquote class="footnote"><a name="FOOTNOTE-409" /><p>[409]In fact, it would generally be a lie to say that a Perl arrayis stored in "a chunk of memory" at all, as it'salmost certainly spread among many separate chunks.</p></blockquote></div><a name="lperl3-APP-B-SECT-13.2" /><div class="sect2"><h3 class="sect2">B.13.2. Sockets</h3><p>Perl has full support for <a name="INDEX-1262" /> <a name="INDEX-1263" />TCP/IP sockets, which means that youcould write a web server in Perl, or a web browser, Usenet newsserver or client, finger daemon or client, FTP daemon or client, SMTPor POP or SOAP server or client, or either end of pretty much anyother kind of protocol in use on the<a name="INDEX-1264" />Internet. Of course, there's no needto get into the low-level details yourself; there are modulesavailable for all of the common protocols. For example, you can makea web server or client with the<tt class="literal">LWP</tt><a name="INDEX-1265" /> module and one or two lines ofadditional code.<a href="#FOOTNOTE-410">[410]</a> The <tt class="literal">LWP</tt> module (actually,a tightly integrated set of modules, which together implement nearlyeverything that happens on the Web) is also a great example ofhigh-quality Perl code, if you'd like to copy from the best.For other protocols, search for a module with the protocol'sname.</p><blockquote class="footnote"> <a name="FOOTNOTE-410" /><p>[410]Although <tt class="literal">LWP</tt>makes it easy to make a simple "web browser" that pullsdown a page or image, actually rendering that to the user is anotherproblem. You can drive an X11 display with Tk or Gtk widgets though,or use curses to draw on a character terminal. It's all amatter of downloading and installing the right modules fromCPAN.</p> </blockquote></div><hr width="684" align="left" /><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="appb_12.htm"><img alt="Previous" border="0" src="../gifs/txtpreva.gif" /></a></td><td align="center" valign="top" width="228"><a href="index.htm"><img alt="Home" border="0" src="../gifs/txthome.gif" /></a></td><td align="right" valign="top" width="228"><a href="appb_14.htm"><img alt="Next" border="0" src="../gifs/txtnexta.gif" /></a></td></tr><tr><td align="left" valign="top" width="228">B.12. Formats</td><td align="center" valign="top" width="228"><a href="index/index.htm"><img alt="Book Index" border="0" src="../gifs/index.gif" /></a></td><td align="right" valign="top" width="228">B.14. Security</td></tr></table></div><hr width="684" align="left" /><img alt="Library Navigation Links" border="0" src="../gifs/navbar.gif" usemap="#library-map" /><p><p><font size="-1"><a href="copyrght.htm">Copyright © 2002</a> O'Reilly & Associates. All rights reserved.</font></p><map name="library-map"><area shape="rect" coords="1,0,85,94" href="../index.htm"><area shape="rect" coords="86,1,178,103" href="../lwp/index.htm"><area shape="rect" coords="180,0,265,103" href="../lperl/index.htm"><area shape="rect" coords="267,0,353,105" href="../perlnut/index.htm"><area shape="rect" coords="354,1,446,115" href="../prog/index.htm"><area shape="rect" coords="448,0,526,132" href="../tk/index.htm"><area shape="rect" coords="528,1,615,119" href="../cookbook/index.htm"><area shape="rect" coords="617,0,690,135" href="../pxml/index.htm"></map></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -