Bug #48249 [Com]: socket_read() not returning on no more data to read
| From: | payahnih at hotmail dot com | Date: | Wed, 29 Sep 2010 02:15:31 +0000 |
| Subject: | Bug #48249 [Com]: socket_read() not returning on no more data to read | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-154726@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=48249&edit=1
ID: 48249
Comment by: payahnih at hotmail dot com
Reported by: z4ns4tsu at gmail dot com
Summary: socket_read() not returning on no more data to read
Status: No Feedback
Type: Bug
Package: Sockets related
Operating System: Windows XP
PHP Version: 5.2.9
Block user comment: N
New Comment:
I experienced the same issue on Windows XP, PHP 5.3.3.
It is silly trying to reproduce the issue in Linux, where as the problem
is happening under Windows XP, as in the original report.
Previous Comments:
------------------------------------------------------------------------
[2009-07-10 01:00:01] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
[2009-07-02 22:09:25] jani@php.net
Please provide a complete but short example script. I can not reproduce
this with proper script and using Linux.
------------------------------------------------------------------------
[2009-05-18 19:30:37] z4ns4tsu at gmail dot com
string(133) "250-nameofdomain.com [192.168.10.100], this server offers 4
extensions
250-AUTH LOGIN
250-SIZE 30485760
250-HELP
250 AUTH=LOGIN
"
And then it hangs.
------------------------------------------------------------------------
[2009-05-14 21:58:20] jani@php.net
What DOES it return? Put 'var_dump($out);' inside the loop.
------------------------------------------------------------------------
[2009-05-12 19:54:08] z4ns4tsu at gmail dot com
Description:
------------
I am initiating a socket to an SMTP server to send a message. After
transmitting the EHLO, I need to wait for a variable number of lines to
be returned, so I am using a do{..}while() loop to check if there is
nothing more to be read from the socket before sending the next command.
The program, however, falls into an endless wait because socket_read()
is never returning an empty string (like the documentation says it will)
or FALSE (like some other bug reports say it will).
I have tried with both the PHP_BINARY_READ and PHP_NORMAL_READ flags set
as well as with no flags set at all.
Reproduce code:
---------------
foreach($mail_head as $in) {
$output = "";
$in .= "\r\n";
echo $in;
@socket_write($socket, $in, strlen($in)) or die("Error writing to
socket: " . socket_strerror(socket_last_error()));
do {
$out = false;
$out = socket_read($socket, 1024);
$output .= $out;
} while($out !== false && $out !== '');
if(!preg_match('/^[23]/', $output)) {
die("Error: Mail server did not return the expected response.");
}
}
Expected result:
----------------
EHLO fake.domain
250-this server offers 4 extensions
250-AUTH LOGIN
250-SIZE 30485760
250-HELP
250 AUTH=LOGIN
MAIL FROM:<address@fake.domain>
250 Requested mail action okay, completed
...
Actual result:
--------------
EHLO fake.domain
<nothing>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=48249&edit=1