Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Socket programming in Perl

by dxxd116 (Beadle)
on Aug 30, 2010 at 18:30 UTC ( [id://858062] : perlquestion . print w/replies, xml ) Need Help??

dxxd116 has asked for the wisdom of the Perl Monks concerning the following question:

Hello, Monks: May anyone here recommend some good books or tutorial on socket programming with perl? Thanks a a lot.

Replies are listed 'Best First'.
Re: Socket programming in Perl
by hari9 (Sexton) on Aug 30, 2010 at 18:52 UTC
    Networking Programming with Perl by Lincoln.D.Stein


      Very good book.

      Updated: sorry dxxd116, I was referring to Networking Programming with Perl by Lincoln.D.Stein mentioned hari9 in the previous post.

      Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."

        What is the book title and author?
Re: Socket programming in Perl
by zentara (Archbishop) on Aug 31, 2010 at 10:24 UTC
    UPDATE: The code links below may have gone stale, but the code and tutorial is still available at

    Here is a great free tutorial that walks you thru well-commented code. Scroll down to the Perl section at UNO perl socket tutorial

    That tutorial teaches you from the basics, but you can then see how the modules IO::Select and IO::Socket make life alot easier.

    A good problem to work thru, to gain a good understanding of sockets, is to convert the Socket based code of the good professor, to use IO::Sockets and IO::Select.

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
      Dead link is dead. 404 error when trying that UNO link.
Re: Socket programming in Perl
by chuckbutler (Monsignor) on Aug 30, 2010 at 20:44 UTC

      ISBN 0201615711 is perhaps a better link [isbn://0201615711] produces that using the PM shortcut, and you get a comparison of prices and shipping times that way.

      I'd like to recommend a book not specific to Perl. Actually the code is in C. It's applicable to any language and is the most authoritative text I've ever encountered. It's Unix Network Programming originally by W. Richard Stevens and updated after his death by Bill Fenner and Andrew M. Rudoff. The third edition is ISBN 0131411551, which is more modern than my copy. It leaves out technologies that are no longer relevant, and spends those pages on fuller coverage of what matters. I can;t vouch for the third edition specifically, but it should be really good stuff.

      A handy book that gives useful information on implementing applications that use different network protocols is Internet Core Protocols: The Definitive Guide (ISBN 9781565925724) which includes Perl examples but not exclusively. It comes with a CD which contains all the ISC RFCs and STDs up to a point in time, too.

Re: Socket programming in Perl
by ctilmes (Vicar) on Sep 01, 2010 at 11:44 UTC
    Good books, etc. have already been recommended, if you really want to get into socket programming. (And I do think it is useful to learn about sockets and socket programming even if you don't end up working at that level).

    That said, I think the number of people working at the "socket" layer and writing socket layer applications is (thankfully) getting smaller and smaller as better solutions at higher layers are available.

    Think seriously about your application, and your protocol and what is the appropriate approach to it. CPAN is full of great higher level protocols where someone has already written the socket code for you in a module you can just use. Even if you have to invent a whole new protocol, it is often feasible to ride on top of something like HTTP that has solved many of the hard problems for you.