проверка бинарного канала

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#! /usr/bin/php
<?php
$fh = fopen('/dev/cronyx/ce0', 'r+');
if ($fh===false) {
die("can't open ce0 for\n");
}
$datawrite = "123456789012345678901234567890";
for ($i=0; $i<100; $i++) {
$len = fwrite($fh, $datawrite);
echo date(DATE_RFC822) , "\twrote " , $len , " bytes\n";
$dataread = fread($fh, $len);
echo date(DATE_RFC822) , "\tread " , strlen($dataread) , " bytes : '" , $dataread."'\n";
if ($datawrite !== $dataread) {
die("data is not equal!\n");
}
}
fclose($fh);