Summary


 
Network Programming with Perl
By Lincoln  D.  Stein
Slots : 1
Table of Contents
Chapter  5.   The IO::Socket API

    Content

The object-oriented IO::Socket library significantly simplifies network programming by eliminating much of the "noise code" handed down from the socket API's C heritage and replacing it with a clean and convenient interface. Throughout the remainder of this book we create IO::Socket objects using the class's flexible new() method, and use its object methods whenever they offer a clear syntactic advantage (e.g., $sock->accept() ). In cases where there is no clear syntactic advantage, for example between read ( $sock,$data,1024 ) and $sock->read ( $data,1024 ), we use the Perl built-ins in order to benefit from the performance gains.

With the IO::Socket module it is easy to write simple client and server programs, such as the Web client and the reverse echo server demonstrated in this chapter. However, things became unexpectedly complicated when we tried to write a seemingly trivial tool to echo user commands to a server and back again. We solved this by creating two processes using fork() . The struggle against deadlock is a recurring theme in this book, which we deal with again in later chapters.

You have now learned how to build network applications on top of the low-level socket libraries. The next part of this book moves up a level, showing you how to interact with application-level protocols.


   
Top


Network Programming with Perl
Network Programming with Perl
ISBN: 0201615711
EAN: 2147483647
Year: 2000
Pages: 173

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net