Problems with keep-alive connections

  • Thread starter Vincent van Scherpenseel
  • Start date
V

Vincent van Scherpenseel

Hello group,

I'm writing a simple script which should connect to a HTTP proxy server,
then send a GET request and display the output of the GET request. After
that it should continue with other tasks.

It's all going well, until I use HTTP/1.1. Most HTTP/1.1 requests are
Keep-Alive connections and thus perl keeps the connection (IO::Socket)
alive.

Here's a (much) simplified version of my code:
while (<$remote>) {
print $client $_;
}
close $remote;

Now my problem is that because of the Keep-Alive connection, my script
'hangs' within the while-loop, and thus doesn't continue its operations. Is
there a way to support Keep-Alive connections but still let my script
continue like it should?

Please help me how to work around this.

Yours Sincerely
Vincent van Scherpenseel
 
B

Ben Morrow

Quoth Vincent van Scherpenseel said:
Hello group,

I'm writing a simple script which should connect to a HTTP proxy server,
then send a GET request and display the output of the GET request. After
that it should continue with other tasks.

It's all going well, until I use HTTP/1.1. Most HTTP/1.1 requests are
Keep-Alive connections and thus perl keeps the connection (IO::Socket)
alive.

Here's a (much) simplified version of my code:

Now my problem is that because of the Keep-Alive connection, my script
'hangs' within the while-loop, and thus doesn't continue its operations. Is
there a way to support Keep-Alive connections but still let my script
continue like it should?

You should be using LWP to make the requests; this will deal with
Keep-alive for you (and probably disable it).

Ben
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top