[plt-scheme] Re: peek-bytes-avail!* caching results???

From: Corey Sweeney (corey.sweeney at gmail.com)
Date: Mon Mar 12 12:15:02 EDT 2007

I found my issue.  peek-bytes-avail!* works fine.  The issue was that
the system clock ran the opposite way then I would have expected.

> (require (lib "19.ss" "srfi"))
> (time-nanosecond (current-time))(time-nanosecond (current-time))(time-nanosecond (current-time))

(time is counting down, not up)  This was causing the delays.  Instead
i now just use:


and things work fine.


On 3/11/07, Corey Sweeney <corey.sweeney at gmail.com> wrote:
> I'm getting a wierd phenominon that cycles every 500ms.  does
> peek-bytes-avail!* cache it's results for 500ms?
> This is my setup:   I'm using
> (define data-log-output (open-output-file data-log-filename 'replace))
> (file-stream-buffer-mode data-log-output 'none)
> to write lines to a file 250 times a second.  I added a "flush", and
> everything seems to work ok, as i can "tail -f --sleep-interval=.001
> {logfile}" and see the updates happen very quickly
> I also use:
> (define data-log-input (open-input-file data-log-filename))
> (file-stream-buffer-mode data-log-input 'none)
> to read the file and each time a new line shows up, transmit it over a
> network port with:
> (define (ready-to-read? input-port)
>   (define dummy (make-bytes 1))
>   (define dummy2 (port-progress-evt input-port))
>   (not (zero? (peek-bytes-avail!* dummy 0 dummy2 input-port))))
> (if (ready-to-read? data-log-input)
>    (display (read data-log-input) network-out-port))
> it all works, however it only seems to write to the network in a big
> pulse about every 500ms.  Does peek-bytes-avail!* ever cache it's
> results, and report 0 when it's called, if it was just called
> recently?
> Corey
> --
> ((lambda (y) (y y)) (lambda (y) (y y)))

((lambda (y) (y y)) (lambda (y) (y y)))

Posted on the users mailing list.