By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,521 Members | 1,447 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,521 IT Pros & Developers. It's quick & easy.

Timeouts for blocking calls

P: n/a
I am attempting to write to a named pipe using fwrite(). Unfortunately
fwrite() will block until the pipe is read by an external program. This
call does not have a timeout parameter and I have not seen any equivalent
calls that do. I have been looking for a callback routine so that fwrite()
does not block forever. Something like this:

function no_reader() {
echo "Could not write to pipe";
exit(-1);
}

$pipe = fopen("/tmp/pipe","w");
$cb = callback_new("no_reader", 5); // Call no_reader() in 5 seconds.
fwrite($pipe,"some text");
callback_destroy($cb); // Stop the callback because fwrite() returned.

Is there anything in PHP that can do something like this?
--
Steven Farlie
Jul 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi Steven!

On Tue, 09 Sep 2003 16:17:37 +0200, Steven Farlie
<st***********@blip.anu.blip.edu.blop.au> wrote:
I am attempting to write to a named pipe using fwrite(). Unfortunately
fwrite() will block until the pipe is read by an external program. This
call does not have a timeout parameter and I have not seen any equivalent
calls that do. I have been looking for a callback routine so that fwrite()
does not block forever. Something like this:

function no_reader() {
echo "Could not write to pipe";
exit(-1);
}

$pipe = fopen("/tmp/pipe","w");
$cb = callback_new("no_reader", 5); // Call no_reader() in 5 seconds.
fwrite($pipe,"some text");
callback_destroy($cb); // Stop the callback because fwrite() returned.

Is there anything in PHP that can do something like this?

I think I saw the functionality in the socket functions, but they also
seem to be very buggy. I would recommend a perl or c wrapper for this.

HTH, Jochen

--
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Jul 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.