This is a discussion on Timeouts for blocking calls within the PHP Language forums, part of the PHP Programming Forums category; I am attempting to write to a named pipe using fwrite(). Unfortunately fwrite() will block until the pipe is read ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
Hi Steven!
On Tue, 09 Sep 2003 16:17:37 +0200, Steven Farlie <steven.farlie@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/ |