[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: strange behavior reading lines from a pipe
From: |
CdeMills |
Subject: |
Re: strange behavior reading lines from a pipe |
Date: |
Mon, 8 Jul 2013 00:50:50 -0700 (PDT) |
Mario Storti wrote
> Hi all,
>
> I need to synchronize Octave with a C++ program. The program sends to
> Octave (which is running a script) a double, Octave computes some
> information, saves to disk, and sends back an OK to the C++ program. The
> problem I have is that it seems that Octave is one line lagged with
> respect to what I send.
The problem probably lies deeper. The pipe buffers some data before sending
them out, in order to reduce awaking the other side very often with small
data packets. Try opening the pipe, associate a FILE* to it, then use
setvbuf to put the stream in line-buffered mode. Another approach is to call
fflush each time you wrote some data to make them immediately available.
Regards
Pascal
--
View this message in context:
http://octave.1599824.n4.nabble.com/strange-behavior-reading-lines-from-a-pipe-tp4655302p4655310.html
Sent from the Octave - General mailing list archive at Nabble.com.