I am reading a stream using '$input = trim(fread($socket, 16384));' and everything is working fine until the length of data from the stream exceeds 4078. At 4078 I stop for some reason reading the stream.
I am wondering why this works (up to 4078): '$input = trim(fread($socket, 16384));'
But this does not: '$input = stream_get_contents($socket);'
Other parameters for the stream are:
stream_set_blocking($con, true);
stream_socket_enable_crypto($con, true, STREAM_CRYPTO_METHOD_TLS_SERVER);
handle_incoming_connection($con, $client);
$res = stream_context_create($streamopts);
if ($res === false) {
System_Daemon::err('error when creating stream');
System_Daemon::stop();
exit(1);
}
$master = stream_socket_server(
"tcp://$host:$port", $errno, $errstr, STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, $res
);
if ($master === false) {
System_Daemon::err('stream_socket_server(): [%s] %s', $errno, $errstr
);
System_Daemon::stop();
exit(1);
}
stream_socket_enable_crypto($master, false);
function handle_incoming_connection($socket, $client) {
$input = trim(fread($socket, 16384));
if (($input == null)
|| ($input == 'exit')
) {
return;
}
Any help would be greatly appreciated.
TIA, Jeff