[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: drain-input
From: |
Gary Houston |
Subject: |
Re: drain-input |
Date: |
24 Aug 2001 17:20:04 -0000 |
> From: Alex Shinn <address@hidden>
> Date: 24 Aug 2001 11:11:05 -0400
>
> Could someone explain the purpose of drain-input? My first impression
> was that it would read all remaining input from an input port, so that
> you could do the following:
>
> (define (file-contents file)
> (call-with-input-file file drain-input))
>
> but this doesn't work, and on playing with drain-input it seems to be
> working more with the internal port buffering. For example:
>
> (define p (open-input-file foo)) ; str is
> (define str (drain-input p)) ; ""
> (unread-char #\x p)
> (set! str (drain-input p)) ; "x"
> (set! str (drain-input p)) ; ""
> (peek-char p)
> (set! str (drain-input p)) ; entire contents of foo
>
> Is this the correct behaviour? What is drain-input really doing?
It's returning the contents of the port input buffers. It's possibly
useful for syncing buffered input for operations that act directly
on the file descriptor.
> (set! str (drain-input p)) ; entire contents of foo
Only if less than the buffer size, typically 4096 bytes.
- drain-input, Alex Shinn, 2001/08/24
- Re: drain-input,
Gary Houston <=
- Re: drain-input, Neil Jerram, 2001/08/27
- Re: drain-input, Rob Browning, 2001/08/29
- Re: drain-input, Dale P. Smith, 2001/08/30
- Re: drain-input, Rob Browning, 2001/08/30
- Re: drain-input, Dale P. Smith, 2001/08/30
- Re: drain-input, Chris Cramer, 2001/08/30
- Re: drain-input, Alex Shinn, 2001/08/30