Timeouts for blocking calls

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-09-2003
Steven Farlie
 
Posts: n/a
Default Timeouts for blocking calls

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
Reply With Quote
  #2 (permalink)  
Old 09-11-2003
Jochen Daum
 
Posts: n/a
Default Re: Timeouts for blocking calls

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/
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:19 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0