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

LWP socket connection

by majo (Novice)
on May 30, 2012 at 14:30 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-19 11:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found