Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

IO::socket module or creating by hand

by sajanagr (Acolyte)
on Jun 14, 2010 at 10:09 UTC ( #844553=perlquestion: print w/replies, xml ) Need Help??
sajanagr has asked for the wisdom of the Perl Monks concerning the following question:


I want to create a socket for my code and a beginner.

I want to create a clean code which will enhance slowly in future.

Now, I came to know there is two way to code socket in Perl.

1. using IO:: Socket module

2. Creating sockets and handling them by hand

the second approach has better control as far as i have used.

But, I will like to have your suggestions before starting with this.

Not all who wander are lost ---- /me

Replies are listed 'Best First'.
Re: IO::socket module or creating by hand
by BrowserUk (Pope) on Jun 14, 2010 at 10:41 UTC

    I've never found any lack of "control" using IO::Socket. To my mind, it is one of the best pieces of abstraction on CPAN. Simple, lightweight and very effective.

    Several years ago, I did experiment with creating socket code by hand, and mostly succeeded in get what I set out to do to work. But each time I tried something new, I would re-encounter the same problems and misunderstandings, and inevitably, I would return to the IO::Socket::INET source code to resolve them.

    IO::Socket programs "just work", and so far have never proved to be limiting. That is the very essence of a good module. It may have some limitations, but I haven't encountered them.

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Thanks for your reply and sharing your experience with me. I will look to explore IO::Socket.
Re: IO::socket module or creating by hand
by jettero (Monsignor) on Jun 14, 2010 at 10:37 UTC

    Perl's biggest strength is the CPAN. If you're thinking about opening a socket at all, you're probably missing something. If the socket endpoint is a webserver, look at WWW::Mechanize or LWP. If you're hoping to do SMTP, look at Net::SMTP or MIME::Lite.

    That said, the choice between "by hand" and IO::Socket should be pretty clear, but between the CPAN and IO::Socket you should choose something from the CPAN.

Re: IO::socket module or creating by hand
by pemungkah (Priest) on Jun 19, 2010 at 02:22 UTC
    If you have a definite need to learn how the low-level calls work, then by all means code it yourself. If you want to get a job done, then use the module.

    This is actually a pretty good rule of thumb in general: if you need the nuts and bolts (say you're headed into an area that doesn't have any good modules for it), then write it yourself. If someone else has written a module that covers the ground (and that module, when tested in your application, works -- not all CPAN is perfect), then use the module.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://844553]
Approved by marto
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2018-01-23 06:45 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (240 votes). Check out past polls.