|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-01-11 07:04 UTC] wez@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 00:00:02 2025 UTC |
I have code that would connect to a pop server and retrieve email messages, without using IMAP functions, which worked fine in PHP 4.0 to PHP 4.2.3, but no longer works correctly in PHP 4.3.0. From what I can tell it seems that although the socket shows that it is in blocking mode, it acts as though it is not in blocking mode. The following code demonstrates the problem. With the debug statements added to the code and when it gets to the fgets function, it loops continuously, without reading data from the stream, until the time limit is reached. <?php $hostname = "pop-server"; $port = "110"; $timeout = 30; global $errno, $errstr; $fp = fsockopen ($hostname, $port, $errno, $errstr, $timeout); // debug print_r (socket_get_status ($fp)); echo "<br>\n"; socket_set_blocking ($fp, TRUE); // debug print_r (socket_get_status ($fp)); echo "<br>\n"; $continue = 1; while ($continue) { $chr = fgets ($fp, 1); $str .= $chr; // debug echo "chr = $chr<br>\n"; $array = explode ("\r\n", $str); if ($str != $array[0]) { $continue=0; } } fclose ($fp); ?> Output from version 4.3.0: Array ( [stream_type] => socket [unread_bytes] => 0 [timed_out] => [blocked] => 1 [eof] => ) Array ( [stream_type] => socket [unread_bytes] => 0 [timed_out] => [blocked] => 1 [eof] => ) chr = chr = chr = . . (Loops continuously) . chr = Fatal error: Maximum execution time of 30 seconds exceeded in f:\httproot\popcorn0.8.2\includes\popcorn.inc on line 110 Output from version 4.2.3: Array ( [timed_out] => [blocked] => 1 [eof] => [unread_bytes] => 0 ) Array ( [timed_out] => [blocked] => 1 [eof] => [unread_bytes] => 0 ) chr = + chr = O chr = K chr = chr = C chr = u chr = b chr = i chr = c ... chr = . chr = n chr = e chr = t chr = > chr = chr = I realize that fsockopen, opens the stream in blocking mode by default, but I had to use socket_set_blocking prior to version 4.3.0 to get it to work properly. I tried using stream_set_blocking with the same results. Also, I have tried connecting to multiple POP mail servers with the same result. Only when I go back to version 4.2.3, does it work properly.