script doesn't terminate

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
i've written a php script to test proxy servers, but when i run it
from the command line, it doesn't terminate.  i have to hit Ctrl+C to
terminate it.  so, any ideas as to what i'm doing wrong, and how i
could fix it?  here's the code:

   $address = 'whatever';
   $port = 80;
   $proxy = fsockopen("tcp://$address", (int) $port, $errno, $errstr,
      or exit('Failed - Can Not Open Socket Connection');
   fputs($proxy,"GET"> HTTP/1.1\r\nHost:">\r\n\r\n");
   while (!feof($proxy))
      print fgets($proxy);

i'm using PHP 4.3.9 on Windows XP.

Re: script doesn't terminate

[ctrl-c to stop script]
Quoted text here. Click to load it\r\n\r\n");
Quoted text here. Click to load it

You are making a HTTP/1.1 connection, so the server (or proxy) might
keep-alive the connection. Possible solutions:
-use HTTP/1.0 (_with_ a Host header)
-send the header: Proxy-Connection: close
-send the header: Connection: close

Re: script doesn't terminate

Quoted text here. Click to load it

every one of those solutions worked - thanks! :D

Site Timeline