#29726 [Opn->Fbk]: Streams socket functionality
| From: | tony2001@php.net | Date: | Mon, 14 Feb 2005 23:17:45 +0000 |
| Subject: | #29726 [Opn->Fbk]: Streams socket functionality | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-74067@lists.php.net to get a copy of this message | ||
ID: 29726
Updated by: tony2001@php.net
Reported By: lists at cyberlot dot net
-Status: Open
+Status: Feedback
Bug Type: Sockets related
Operating System: Fedora Core 2
PHP Version: 5.0.1
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.0-win32-latest.zip
Previous Comments:
------------------------------------------------------------------------
[2004-09-10 13:58:59] wez@php.net
Please be more specific in what the problem is.
Note:
- PHP fgets() is line based and binary safe, changing it would break
things. It only returns lines, or the last partial line before the
socket (or file) is closed.
- If you want to break lines on multiple different characters, you need
to code your own buffer handling yourself. See stream_socket_select()
for a way to avoid blocking and writing multiplexing socket servers.
------------------------------------------------------------------------
[2004-08-18 21:09:35] lists at cyberlot dot net
This problem only exists with fread, fget which multiple examples in
the docs use and the docs list as "See Also" functions.
However by using stream_socket_recvfrom this problem was resovled..
This function is not at this time referenced in the manual other in the
functions list so might easily overlooked as I did.
One possible issue I do see, stream_socket_recvfrom looks to work
because it pulls everything in the buffer up to X bytes regardless of
any EOL character. On a slow single line entry settup this shouldn't be
a problem and everything should work fine..
Under high load when data ends up being buffered at both sides this
function would return only partial "blocks" of what a user might expect
and the user would need to program his own internal buffering that
checks for EOL.
This should be covered in more detail in the online manual.
------------------------------------------------------------------------
[2004-08-18 00:59:26] lists at cyberlot dot net
Description:
------------
switched from socket functions to stream functions for socket server
usage because streams is supposed to be stable, and are included by
default..
The problem socket_read supports PHP_NORMAL_READ which allows it to
see flashes \0 as EOL...
This is not possible when using streams to create a socket server as
fget does not see \0 as EOL
Expected result:
----------------
Expect fgets to return data at \0
Actual result:
--------------
Nothing is returned until the buffer is filled.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=29726&edit=1