Re: impossible?

Jens.Toerring_at_physik.fu-berlin.de
Date: 08/07/04

  • Next message: Alvin SIU: "Re: ANother simple problem"
    Date: 7 Aug 2004 14:13:16 GMT
    
    

    Alex Jones <dontlikespam@email.com> wrote:
    > "Barry Margolin" <barmar@alum.mit.edu> wrote in message
    > news:barmar-631F5F.00434907082004@comcast.dca.giganews.com...
    >> In article <cf0po5$91h$07$1@news.t-online.com>,
    >> "Alex Jones" <dontlikespam@email.com> wrote:
    >> > I'm trying to implement synchronous interprocess communication where
    > the
    >> > reader blocks until data is available and (the important thing) the
    >> > sender blocks until the sent data is fully read by the other side. I
    >> > thought this could be done using a pty/tty couple, but the sender
    >> > continues execution before the data has been read, so that it seems
    > the
    >> > data is somewhere buffered. I know that such a communication will
    > reduce
    >> > performance, but that doesn't matter in this case. The man page for
    >> > open(..) showed the a flag O_SYNC, which doesn't make any
    > difference.
    >> > Another interesting flag is O_DIRECT, which doesn't seem to be
    > defined.
    >> > cfmakeraw() didn't work either.
    >>
    >> I don't think any of the standard IPC mechanisms provide this feature.
    >> I suggest you use a semaphore to implement the blocking. After the
    >> writer writes his data, he waits on the semaphore, which the reader
    >> signals after he has completed reading the data.

    > Thanks for your response, but that won't be possible, because the child
    > process (the writer) will be a compiled program (using execlp() ) later,
    > not written by me. But is it really _impossible_ to just create a
    > completely unbuffered stream for communication??

    When you have no control about the writer how should you be able to
    control if it writes without buffering? If the writer uses e.g. the
    C standard I/O function and doesn't set them explicitely to unbuf-
    fered mode there's hardly anything you can do about that (short of
    fiddling with the libc it's using) - the data will stay in the
    writers side I/O buffer (controlled by the I/O functions) which will
    only get flushed when it's full (if the writer thinks it's writing
    to a file) or if there's a '\n' is in the stream (if the writer
    assumes to be writing to a terminal). What you can achieve with
    a set of pty's in between the processes is making the writer believe
    it's talking to a terminal, thus flushing it's buffers on '\n', but
    not more.

    What kind of a program are you trying to write where on the one hand
    you want absolute control about details like buffering down to a
    single byte level but on the other hand you have no influence about
    the behavior of the sides? If you would give a bit more of a complete
    picture perhaps there are alternatives you didn't take into account
    yet.
                                          Regards, Jens

    -- 
      \   Jens Thoms Toerring  ___  Jens.Toerring@physik.fu-berlin.de
       \__________________________  http://www.toerring.de
    

  • Next message: Alvin SIU: "Re: ANother simple problem"

    Relevant Pages

    • Re: How to know when WriteStreamSample has written the sample to d
      ... They are read from source file in the ... correct order and written to the asf-file. ... I was hoping that it's somehow possible to control that buffering but I have ... There's of course not an option that the writer starts dropping samples, ...
      (microsoft.public.windowsmedia.sdk)
    • Re: ControlAdapter sample from Scott Gu no more work ?
      ... Using url rewritting and ajax.net, I tried to circumvent some potential problems with postback url using a code from a sample given by Scott. ... The idea is to use a control Adapter on htmlform to catch the attribute 'action' wich contains the url where the post will occur and replace it with a safe url. ... protected override void Render(System.Web.UI.HtmlTextWriter writer) ...
      (microsoft.public.dotnet.framework.aspnet)
    • Re: How to know when WriteStreamSample has written the sample to d
      ... However I still think we are talking about different reason for the buffering. ... Like I said it's nothing about the timestamp not arriving in the correct ... I don't understand why the writer should wait for more samples when it ... but it writes the data when the buffered streams ...
      (microsoft.public.windowsmedia.sdk)
    • Re: How to know when WriteStreamSample has written the sample to d
      ... If the writer is not writing out the data, ... but it writes the data when the buffered streams ... are more or less in sync. ... steadily without too much buffering. ...
      (microsoft.public.windowsmedia.sdk)
    • Cannot add web control to allitems.aspx
      ... I have written a web control and it renders just fine in a site's ... bstrUrl, String bstrListName, String bstrListProperty) +0 ... System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243 ...
      (microsoft.public.sharepoint.windowsservices)