473,325 Members | 2,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

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_timeout($proxy,1);
fputs($proxy,"GET 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.
Jul 17 '05 #1
2 2351
yawnmoth <te*******@yahoo.com> wrote:
[ctrl-c to stop script]
$proxy = fsockopen("tcp://$address", (int) $port, $errno, $errstr,
1)
or exit('Failed - Can Not Open Socket Connection');
stream_set_timeout($proxy,1);
fputs($proxy,"GET http://www.google.com/ HTTP/1.1\r\nHost: > www.google.com\r\n\r\n");
while (!feof($proxy))
print fgets($proxy);
fclose($proxy);


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

Jul 17 '05 #2
Daniel Tryba <sp**@tryba.invalid> wrote in message news:<41***********************@dreader3.news.xs4a ll.nl>...
<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


every one of those solutions worked - thanks! :D
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Boris Nikolaevich | last post by:
This is backwards of what I usually want--normally if you have a long-running ASP script, it's a good idea to check to see whether the client is still connected so you can cancel execution. ...
9
by: Adam | last post by:
I was looking for a way to just catch any exception throw. Given the postings, it looks like catch(...) should do it, except it doesn't. Maybe C++ is suppose to work this way, or maybe this is a...
5
by: Helmut Jarausch | last post by:
Hi, I'm still looking for an elegant and clear means to terminate the main script in Python. Unfortunately, Python doesn't allow a 'return' instruction in the main script. Using...
9
by: adamalton | last post by:
I've got a script which uses cURL to connect to another website, and it seems to be getting stuck (I can't quite figure out how, but that's besides the point!). The trouble is that when my script...
3
FishVal
by: FishVal | last post by:
Windows Script Host Object library. Full name: Windows Script Host Object Model LibName: IWshRuntimeScripting Location: ...\WINDOWS\system32\wshom.ocx The present tip is closely related to...
3
by: WP | last post by:
Hello, I have a very simple script (or would you call it a batch file?) with the following content: connect to mydb2; DROP TABLE staff_employee_address; DROP TABLE...
3
by: Gros Bedo | last post by:
Hello :-) I have a question about Python and Linux shell. I have a python program which is permanently resident in the end-user system. I'm currently producing a RPM package, and it works nicely....
1
by: Gros Bedo | last post by:
Yes I've seen that each python script calls its own instance of Python. Buthow to know which is the good one in bash ? Is there a command that gets the parameters of process, so I could use grep to...
0
by: norseman | last post by:
Gros Bedo wrote: ============================== Yes. man ps explains try ps -AFL | grep then kill -9 found (check it more than twice) 1) If your script is known to hang use what...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.