Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

LWP socket connection

by majo (Novice)
on May 30, 2012 at 14:30 UTC ( #973297=perlquestion: print w/replies, xml ) Need Help??
majo has asked for the wisdom of the Perl Monks concerning the following question:

HI I read in one of the books that using LWP is faster and cleaner than using sockets. Can someone please explain how is this possible. Furthermore would be correct to say that LWP::Simple and LWP::UserAgent imitates the functions of a browser? Thanks.

Replies are listed 'Best First'.
Re: LWP socket connection
by Eliya (Vicar) on May 30, 2012 at 14:52 UTC
    using LWP is faster and cleaner than using sockets

    If with "faster" you mean "less time required to write the code", then presumably yes, because LWP provides a higher level programming interface than plain sockets, so you need to write less code to achieve the same effect.

    OTOH, if "faster" means "runs faster", it wouldn't make much sense, as LWP uses sockets under the hood...  so you could (in theory) always write low-level socket code that runs at least as fast.

Re: LWP socket connection
by bulk88 (Priest) on May 30, 2012 at 22:01 UTC
    Raw sockets with custom http parser will run faster than LWP. LWP is much faster to write the code with.
      what I meant was the speed of download time and also response times from the server. what is it like compared to other scripting languages like javascript, php, python etc when calculating response times

        In general, with a typical internet connection, the choice of programming language won't have a significant impact on download times.  Unless your network, and the server on the other end, are extremely fast, the time spent by the client program creating sockets, shoveling bytes program-internally, etc., will be roughly one or two orders of magnitude less than the time spent waiting for things that go on program-externally, and are thus out of control of the program(-ming language).

        As always, if you really want to know, write simple test programs, and benchmark them in a controlled environment.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://973297]
Approved by Corion
[ww]: or a lot more than (22*2) for /me
[ww]: er -- senior cognitive deficiency: ((22+(22*2))
[ww]: (but pls don't s/senior/senile/ ... not yet
[karlgoethebier]: A bit more audience now: The Impact of Information Sources on Code Security Very interesting IMHO...
[karlgoethebier]:'s about copy & paste ;-)
[ww]: Wonder what IEEE would have thought w/survey based on PM/perl
[ww]: s/thought/found/
[erix]: that title is a broken* sentence, no? But maybe that's deliberate
[karlgoethebier]: ww:My first thought, to be honest...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (10)
As of 2017-09-25 14:43 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (280 votes). Check out past polls.