pid_lseek()


int pid_lseek ( int $pid, int $offset [ , int $whence = SEEK_SET ] )

Описание

pid_lseek() перемещает read/write смещаения PID

Параметры

Возврат значений

Возращает смещение от начала, при ошибке PHP появится error.

Пример

<?php

$buf = "ABCDEFGHIJKLMNOPabcdefghijklmnop";

$pid_um = pid_open("/mmap/um1");  // /mmap/um1 buffer size is 64

pid_lseek($pid_um, 0, SEEK_SET);  // set the point to the beginning (position 0)
pid_write($pid_um, $buf, 32);  // write $buf to the position 0 (position changed to 32 after this operation)
pid_lseek($pid_um, 0, SEEK_SET);  // set the point to the beginning (position 0)
pid_read($pid_um, $buf, 32);  // read 32 bytes from the current position (position 0)
hexdump($buf);  // outputs $buf
// OUTPUT   
// 0000  41 42 43 44 45 46 47 48  49 4a 4b 4c 4d 4e 4f 50  |ABCDEFGHIJKLMNOP|
// 0010  61 62 63 64 65 66 67 68  69 6a 6b 6c 6d 6e 6f 70  |abcdefghijklmnop|

pid_lseek($pid_um, 0, SEEK_SET);  // set the point to the beginning (position 0)
pid_lseek($pid_um, 8, SEEK_CUR);  // set the point to position 8
pid_read($pid_um, $buf, 16); // read 16 bytes from the current position (position 8)
hexdump($buf);  // outputs $buf
// OUTPUT
// 0000  49 4a 4b 4c 4d 4e 4f 50  61 62 63 64 65 66 67 68  |IJKLMNOPabcdefgh|

pid_read($pid_um, $buf, 16);  // read 16 bytes from the current position (position 24)
hexdump($buf);
// OUTPUT
// 0000  69 6a 6b 6c 6d 6e 6f 70  00 00 00 00 00 00 00 00  |ijklmnop........|

pid_lseek($pid_um, -48, SEEK_END);  // set the point to 48 from the end (position 16)
pid_read($pid_um, $buf, 16);  // read 16 bytes from the current position (position 16)
hexdump($buf);  // outputs $buf
// OUTPUT
// 0000  61 62 63 64 65 66 67 68  69 6a 6b 6c 6d 6e 6f 70  |abcdefghijklmnop|
?>

Смотрите также

pid_open() / pid_close() / pid_ioctl() / pid_read() / pid_write() /

Примечания

Отсутствуют.