[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#30066: 'get-bytevector-some' returns only 1 byte from unbuffered por
From: |
Ludovic Courtès |
Subject: |
bug#30066: 'get-bytevector-some' returns only 1 byte from unbuffered ports |
Date: |
Sat, 13 Jan 2018 21:53:34 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) |
Hey,
Andy Wingo <address@hidden> skribis:
> On Fri 12 Jan 2018 11:15, address@hidden (Ludovic Courtès) writes:
>
>> Andy Wingo <address@hidden> skribis:
>>
>>> On Thu 11 Jan 2018 22:55, Mark H Weaver <address@hidden> writes:
>>
>> [...]
>>
>>>>>> Out of curiosity, is there a reason why you're using an unbuffered port
>>>>>> in your use case?
>>>>>
>>>>> It’s to implement redirect à la socat:
>>>>>
>>>>>
>>>>> https://git.savannah.gnu.org/cgit/guix.git/commit/?id=17af5d51de7c40756a4a39d336f81681de2ba447
>>>>
>>>> Why is an unbuffered port being used here? Can we change it to a
>>>> buffered port?
>>>
>>> This was also a question I had! If you make it a buffered port at 4096
>>> bytes (for example), then get-bytevector-some works exactly like you
>>> want it to, no?
>>
>> It might work, but that’s more by chance no?
>
> No, it is reliable. get-bytevector-some on a buffered port must either
> return all the buffered bytes or perform exactly one read (up to the
> buffer size) and either return those bytes or EOF. As far as I
> understand, that is exactly what you want.
Indeed, that works well, thanks! So, after all, problem solved?
I think the confusion for me comes from the fact that we don’t have a
FILE*/fd distinction like in C. It’s as if we were always using FILE*
in the sense that I’m never sure what’s going to happen or whether a
particular behavior can be relied on.
Thank you,
Ludo’.
- bug#30066: 'get-bytevector-some' returns only 1 byte from unbuffered ports, (continued)
- bug#30066: 'get-bytevector-some' returns only 1 byte from unbuffered ports, Ludovic Courtès, 2018/01/11
- bug#30066: 'get-bytevector-some' returns only 1 byte from unbuffered ports, Mark H Weaver, 2018/01/11
- bug#30066: 'get-bytevector-some' returns only 1 byte from unbuffered ports, Ludovic Courtès, 2018/01/11
- bug#30066: 'get-bytevector-some' returns only 1 byte from unbuffered ports, Mark H Weaver, 2018/01/11
- bug#30066: 'get-bytevector-some' returns only 1 byte from unbuffered ports, Andy Wingo, 2018/01/12
- bug#30066: 'get-bytevector-some' returns only 1 byte from unbuffered ports, Ludovic Courtès, 2018/01/12
- bug#30066: 'get-bytevector-some' returns only 1 byte from unbuffered ports, Andy Wingo, 2018/01/12
- bug#30066: 'get-bytevector-some' returns only 1 byte from unbuffered ports,
Ludovic Courtès <=