writing while reading
| From: | Rui Barreiros | Date: | Wed, 01 Aug 2001 17:23:05 +0000 |
| Subject: | writing while reading | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-60635@lists.php.net to get a copy of this message | ||
hi all,
i'm writing a web chat, the frame that presents the text, has a very fast
refresh (has to) it's about from 2 in 2 seconds, my problem is writing to the
file (chat is file based), when the refresh read the file, it doesn't let php
write. i made comething like this.
Function chat2file($filename, $str) {
$fp = fopen("chats/$filename", "a");
fputs($fp, $str);
close($fp);
}
Function file2chat($filename) {
if(file_exists("chats/$filename")) {
$fd = fopen("chats/$filename", "r");
flock($fd, LOCK_UN);
$content = fread($fd, filesize("chats/$filename"));
fclose($fd);
return $content;
} else {
return "";
}
}
i put the non blocking option in flock while reading but still blocks and
doesn't write, my question is it possible to write to a file while reading?!,
if so how?
thx.
--
Rui Barreiros
Software Developer
WEBSOLUT - Soluções Internet
Emailto: rui@websolut.net
Personal Info: http://websolut.net/people/rui.html
As informações contidas neste email são confidenciais
e destinam-se apenas à(s) pessoa(s) a quem foi enviado:
http://websolut.net/confidencialidade-responsabilidade.html