Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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:

Hi

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

Comment on IO::socket module or creating by hand
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 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 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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://844553]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (9)
As of 2014-09-19 19:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (145 votes), past polls