|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-04-18 09:57 UTC] tech at kalyweb dot com
In the documentation, it's written that socket_read() reads data from the socket until a \n, \t, \0.... or until the end of the buffer.
But under win32 it reads only 1 char.
This would be fixed.
Just use instead :
$buf="";
while (substr($buf,-1)!="\n") {
$buf.=socket_read($socket,1);
}
I've put 1 here, but you can write 16777216 it'll continue to give back only 1 char.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 01:00:02 2025 UTC |
How did you test sending data to your php script which received the data? I've noticed that the telnet version shipped with windows does by default transmit every character immidiately over the line (hence resulting only in single characters sent). If I telnet from a linux host to the script running under win32 I recevied the whole data only after I pressed return. I've tested it with this simple script: <? error_reporting(E_ALL); if (false === ($s = socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) exit; if (false === socket_bind($s, '0.0.0.0', 8765)) exit; if (false === socket_listen($s, 10)) exit; if (false === ($t = socket_accept($s))) exit; while ($data = socket_read($t, 1024)) { var_dump($data); } ?>