Ask a Question related to UNIX Programming, Design and Development.
-
Peteris Krumins #1
Buffered input/output.
Hello,
I am struggling with the following problem:
Two unrelated programs communicate via two fifos (is this a good way of
communicating between two programs?).
The first program opens one fifo for reading (R) and the second fifo
for writing (W), the second program does the same but opens fifos vice
versa, the first fifo for writing and the second fifo for reading.
(Also, can i open these fifos with fopen() without blocking? (I know
about open() and O_NONBLOCK but can i do the same with fopen()?))
The first program writes something to its W fifo, calls fflush(W) and
the second program meanwhile has issued select() on its R fifo,
select() successfully returns, then a fread() follows on R fifo but
it just blocks.
I assume this has something to do with buffered input?
How do i read from the second programs R fifo after the first program
has successfully written something to it?
i tried calling setvbuf(R,NULL,_IONBF,0) but it still does not work.
Also, i am curious - how to auto-flush output (In my case R fifo), so i
didnt have to call fflush() after each write to that fifo?
P.Krumins
Peteris Krumins Guest
-
buffered output?
I have an odd problem... I have a perl script that execs another program: $cmd = "motuds t1.dat t2.dat t3.dat > out1"; exec $cmd; Motuds... -
International Input/Output
I hope somone can offer some advice. I have built a database accepting information through ASP from clients in UK, Germany France and Russia. I set... -
input/output
Hi I need to have lists of inputs and outputs being displayed in to their prospective fields when they are called or typed by user.Say, If the... -
[PHP] Cannot output before input
>ob_flush() Thanks curt, it's working ^_^ -
output/input parameter
i follow this help: http://support.microsoft.com/default.aspx?scid=kb;en- us;209576 to synchronize two combo boxes. the form works but the form... -
Floyd Davidson #2
Re: Buffered input/output.
Peteris Krumins <pkruminsREMOVETHIS@inbox.lv> wrote:
You are using select(), which tells you when a *file descriptor*>Hello,
>
> I am struggling with the following problem:
> Two unrelated programs communicate via two fifos (is this a good way of
> communicating between two programs?).
> The first program opens one fifo for reading (R) and the second fifo
> for writing (W), the second program does the same but opens fifos vice
> versa, the first fifo for writing and the second fifo for reading.
> (Also, can i open these fifos with fopen() without blocking? (I know
> about open() and O_NONBLOCK but can i do the same with fopen()?))
>
> The first program writes something to its W fifo, calls fflush(W) and
> the second program meanwhile has issued select() on its R fifo,
> select() successfully returns, then a fread() follows on R fifo but
> it just blocks.
will block. But then you say you are using fread(), which reads
from a stream (which doesn't block at the same times).
You can't expect to mix calls using fd's and fp's.
Use read() instead of fread(), for example.> I assume this has something to do with buffered input?
> How do i read from the second programs R fifo after the first program
> has successfully written something to it?
What's wrong with using fflush()?> i tried calling setvbuf(R,NULL,_IONBF,0) but it still does not work.
> Also, i am curious - how to auto-flush output (In my case R fifo), so i
> didnt have to call fflush() after each write to that fifo?
--
Floyd L. Davidson <http://web.newsguy.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) [email]floyd@barrow.com[/email]
Floyd Davidson Guest
-
Peteris Krumins #3
Re: Buffered input/output.
Floyd Davidson <floyd@barrow.com> wrote in
news:87r84kemx2.fld@barrow.com:
[...]> Peteris Krumins <pkruminsREMOVETHIS@inbox.lv> wrote:>>Hello,
>>
Oh, thanks for this information. I didn't know this!> You are using select(), which tells you when a *file descriptor*
> will block. But then you say you are using fread(), which reads
> from a stream (which doesn't block at the same times).
> You can't expect to mix calls using fd's and fp's.
Yes, it solved the problem.>>> I assume this has something to do with buffered input?
>> How do i read from the second programs R fifo after the first
>> program has successfully written something to it?
> Use read() instead of fread(), for example.
Nothing is wrong, i just thought there was a method to auto-flush output>>> i tried calling setvbuf(R,NULL,_IONBF,0) but it still does not work.
>> Also, i am curious - how to auto-flush output (In my case R fifo),
>> so i didnt have to call fflush() after each write to that fifo?
> What's wrong with using fflush()?
buffer on each write, so i didnt waste time with fflush() calls.
P.Krumins
Peteris Krumins Guest



Reply With Quote

