|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-04-29 06:45 UTC] wez@php.net
[2002-07-02 16:42 UTC] eru@php.net
[2002-09-24 16:08 UTC] wez@php.net
[2002-10-14 19:26 UTC] phpdoc at lists dot php dot net
[2007-07-13 10:36 UTC] netscoutt at gmail dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 22 09:00:01 2025 UTC |
I'm having trouble reading the data from responses over socket connections. For instance, this code (similar to that on the online docs for fsockopen, example 1), $fp = fsockopen ("localhost", 80, $errno, $errstr, 10); if (!$fp) { echo "$errstr ($errno)<br>\n"; } else { fputs ($fp, "GET / HTTP/1.0\r\nHost: localhost\r\n\r\n"); while (!feof($fp)) { echo fread ($fp,128); } fclose ($fp); } results in a timeout on the fread line (even if I let it run for 300 seconds). I also tried the udp example (example 2, "fsocketopen("udp://127.0.0.1"...) on the documentation page and had the same problem. Also note that the fourth parameter to the fsockopen doesn't seem to be working in this case since this code took 300 seconds to timeout, not the 10 specified. The CPU usage by php went to 100% during the attempted excution of this code. I have the same problem if I try using fopen to open a web page and read the data (as in the below code). It always hangs on the fread or fgets of the file pointer with the response in it. I know the remote service (e.g., the web server) is actually sending a response string because I can see it in the server log. My hardware is a bit unusual. I'm running SuSe linux kernel 2.4.7-SuSe-SMP under VM on an IBM mainframe. I had these errors with php versions 4.2.0, 4.1.2, and 4.0.6. I tried to replicate the problem on an intel box with RedHat 7.2 kernel 2.4.9 and php 4.0.6, but failed. The most abnormal behaviour I could find on that platform was that "fopen" and then "fread" of remote or local web pages took *way* too long. For instance, this code eventually got the desired response, but it took about 20-24 seconds: $fp = fopen("http://localhost/", "r"); $text = fread($fp, 20); fclose($fp); echo $text; If I used fsockopen (e.g., with the first piece of code above) on this box it ran in less than a second and gave the expected response. Any help is much appreciated. I really need to figure out how to read data over sockets on that first machine. Thanks, Graham Warden giwarden@ucla.edu p.s. This is somewhat related to my previous bug post (#10996) about a year ago.