473,232 Members | 1,411 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,232 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 2345
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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...

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.