ID:               21485
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-Status:           Feedback
+Status:           No Feedback
 Bug Type:         Sockets related
 Operating System: Win2K/Linux
 PHP Version:      4.3.0
 Assigned To:      wez
 New Comment:

No feedback was provided for this bug for over 2 weeks, 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".


Previous Comments:
------------------------------------------------------------------------

[2003-01-09 04:33:57] [EMAIL PROTECTED]

The following works for me:

$fp = fsockopen("localhost", 25);
stream_set_blocking($fp, false);
fwrite($fp, "QUIT\r\n");
while(!feof($fp)) {
  $data = fgets($fp);
  var_dump($data);
}
echo "\nAll done\n";

Under Win2000, WinXP, Linux2.4.19 (with IPv6), FreeBSD4.5 (with
IPv6)...

Not verified at all for me.

------------------------------------------------------------------------

[2003-01-09 04:23:45] [EMAIL PROTECTED]

The following works for me:

$fp = fsockopen("localhost", 25);
stream_set_blocking($fp, false);
fwrite($fp, "QUIT\r\n");
while(!feof($fp)) {
  $data = fgets($fp);
  var_dump($data);
}
echo "\nAll done\n";

Remember that feof() will only return true when there is no more data
in the internal buffer held by the stream, so you need to drain off any
input by consuming it all first.

------------------------------------------------------------------------

[2003-01-09 04:05:25] [EMAIL PROTECTED]

The nature of non-blocking sockets means that your script must always
be prepared to handle a false or zero length return from fgets/fread,
so I'm not worried about that aspect.
However, the feof() does seem to be a problem.
Looking into it...

------------------------------------------------------------------------

[2003-01-09 02:48:19] [EMAIL PROTECTED]

I've noticed that I need the sleep() in order to retrieve the data.

The behaviour with blocking/non blocking sockets haven't changed
though, its still the same in php 4.3.0 as it were in previous php
versions.

What has changed is the feof() that never return true.

Regards
/Bjarne

------------------------------------------------------------------------

[2003-01-08 21:40:39] [EMAIL PROTECTED]

It seems that socket_set_blocking($fp,FALSE); results in other peculiar
behaviour.
When connecting to SMTP server, the server sends some data across the
socket right away, usually something identifying the server.

$fp = fsockopen("mail_server", 25);
var_dump(fgets($fp, 1024));
fclose($fp);
returns the server identify string

$fp = fsockopen("mail_server", 25);
socket_set_blocking($fp,FALSE);
var_dump(fgets($fp, 1024));
fclose($fp);

returns (false) 

$fp = fsockopen("mail_server", 25);
sleep(1);
socket_set_blocking($fp,FALSE);
var_dump(fgets($fp, 1024));
fclose($fp);

returns identify string.

The position of the sleep() call can be after socket_set_blocking() as
well.

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/21485

-- 
Edit this bug report at http://bugs.php.net/?id=21485&edit=1

Reply via email to