script doesn't terminate

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • yawnmoth

    script doesn't terminate

    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,
    1)
    or exit('Failed - Can Not Open Socket Connection');
    stream_set_time out($proxy,1);
    fputs($proxy,"G ET http://www.google.com/ HTTP/1.1\r\nHost:
    www.google.com\ r\n\r\n");
    while (!feof($proxy))
    print fgets($proxy);
    fclose($proxy);
    exit();
    ?>

    i'm using PHP 4.3.9 on Windows XP.
  • Daniel Tryba

    #2
    Re: script doesn't terminate

    yawnmoth <terra1024@yaho o.com> wrote:
    [ctrl-c to stop script][color=blue]
    > $proxy = fsockopen("tcp://$address", (int) $port, $errno, $errstr,
    > 1)
    > or exit('Failed - Can Not Open Socket Connection');
    > stream_set_time out($proxy,1);
    > fputs($proxy,"G ET http://www.google.com/ HTTP/1.1\r\nHost: > www.google.com\ r\n\r\n");
    > while (!feof($proxy))
    > print fgets($proxy);
    > fclose($proxy);[/color]

    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

    Comment

    • yawnmoth

      #3
      Re: script doesn't terminate

      Daniel Tryba <spam@tryba.inv alid> wrote in message news:<4191a513$ 0$59397$e4fe514 c@dreader3.news .xs4all.nl>...[color=blue]
      > <snip>
      > 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[/color]

      every one of those solutions worked - thanks! :D

      Comment

      Working...