Bug #1432: fgets() fails on certain sockets

From: Date: Fri, 21 May 1999 08:28:25 +0000
Subject: Bug #1432: fgets() fails on certain sockets
Groups: php.dev 
Request: Send a blank email to php-dev+get-5830@lists.php.net to get a copy of this message
From: adam@musicseek.net Operating system: Win32 PHP version: 3.0.6 PHP Bug Type: Misbehaving function Bug description: fgets() fails on certain sockets I use PHP/3.06 win32 for writing a web crawler which indexes URL's. The indexer has no problems, except on ONE url that I know of so far which seems to be, as far as I can ascertain related to the fgets() function failing to work. fgets() will not read data from any socket connected via fsockopen to www.hutman.com port 80. I know this might seem very strange, but fgets() never seems to be able to determine EOF and hence sits there forever doing nothing. I have used a raw telnet session to try and debug this and cannot find why PHP would do this -- it works fine on every other URL in the database. Here is some code that may help: $sock = fsockopen("www.hutman.com",80); if ($sock) { fputs($sock,"HEAD /dreg/facade/songs/aftk.mp3 HTTP/1.1\n"); fputs($sock,"Host: www.hutman.com\n"); fputs($sock,"User-Agent: HTTP-crawler/1.0\n"); fputs($sock,"Connection: close\n\n"); /* at this point the server responds .. and it indeed does in a telnet session, but PHP simply wont read the data returned AT ALL. */ while ($buf = fgets($sock,128)) { $response = $response . $buf; echo $buf; } No variations of this will work.. the fgets() function will timeout after a while. i have tried while (!feof($sock)) as well, which exhibits similar behaviour, but seems to NEVER return from the fgets() call .. never times out. -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#5830) next »