how to create persisitent tcp connections using perl

S

soniasainani

Hi,

I need to write a perl script to get me a url and then send keep alive
requests at regular intervals. In short, I have to simulate what a
browser doesand as a result, I need to keep my tcp connection
persistent. I am looking for the modules in LWP in Perl. Can you give
me some more details how to go about it?

Thanks and regards,
Sonia Sainani
 
B

burlo.stumproot

Hi,
I need to write a perl script to get me a url and then send keep alive
requests at regular intervals. In short, I have to simulate what a
browser doesand as a result, I need to keep my tcp connection
persistent. I am looking for the modules in LWP in Perl. Can you give
me some more details how to go about it?

Thanks and regards,
Sonia Sainani

First, if you have not done so already please read
the posting guidelines.

http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

Your subject line does not match your question,
this is not the best way to generate helpful replies.

That said.


Look at LWP::Simple.

http://search.cpan.org/~gaas/libwww-perl-5.803/lib/LWP/Simple.pm

You have to be more specific about the url.
Get it from:
a webpage
a file
a user
a space bat
?
 
S

Sherm Pendley

Bernie Cosell said:
This doesn't make sense. Every browser request goes on a *SEPARATE* TCP
connection --- in the context of the web, there's really no concept of a
persistent connection -- when you access a web page, you browser opens a
connection, fetches the page, closes the connection and then begins
processing the HTML... if there's, say, an IMG tag on the page, your
browser opens another connection, fetches the image, etc....

That was true for HTTP 1.0, but 1.1 added "persistent connections" which
allows for multiple requests across a single TCP connection.

Details are here:

<http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html>

sherm--
 
A

Alan J. Flavell

Bernie Cosell <[email protected]> writes:
[in relation to an original posting that doesn't seem to have shown up
here...]
That was true for HTTP 1.0, but 1.1 added "persistent connections"
which allows for multiple requests across a single TCP connection.

While this is true as you stated it, I'm not sure that it really
solves the original question. Usually, HTTP clients do or don't use
this mechanism according to various criteria, behind the scenes,
without it having any direct relevance to any kind of "session" in
progress. And, attempting to prolong the persistence indefinitely
goes very much against the ethos of HTTP, where each URL retrieval
should be seen as an individual transaction at the application level,
no matter what's going on at lower network layers behind the scenes in
the way of HTTP persistent connections.

This looks to me like an X/Y problem: to give a quality answer, we'd
need to know what it is that the questioner *really* needs to achieve,
rather than being told part of what they suppose the solution to be.

http://search.cpan.org/~gaas/libwww-perl/lwptut.pod includes mention
of HTTP/1.1 keep-alive, but, according to the documentation, it only
"tries" to use the feature. Elsewhere in the LWP documentation, there
might be more details. Even if the hon. Usenaut does not want to use
LWP, it might still serve as a source of clues, or a library of
low-level routines to build upon.

regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top