[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading data from a file descriptor

From: Thompson, David
Subject: Re: Reading data from a file descriptor
Date: Sun, 15 Nov 2015 07:05:27 -0500

On Sun, Nov 15, 2015 at 6:09 AM, Jan Synáček <address@hidden> wrote:
> On Fri, Nov 13, 2015 at 9:45 PM, Thompson, David
> <address@hidden> wrote:
>> On Fri, Nov 13, 2015 at 3:41 PM, Jan Synáček <address@hidden> wrote:
>>> I have an open fd to a unix socket and I want to read data from it. I
>>> know that the data is going to be only strings, but I don't know the
>>> length in advance. The good thing about using read-string!/partial is,
>>> that I don't have to specify how many bytes I want to read and it does
>>> the right thing. If you point me to a better direction, I'll be
>>> grateful. I came up with:
>>> (for-each (lambda (fd)
>>>             (let* ((buf (make-string 4096)))
>>>               (read-string!/partial buf (fdes->inport fd))
>>>               (format #t "fd[~a]: ~a" fd buf) (newline)))
>>>           fds)
>> Maybe 'read-string' in (ice-9 rdelim) is what you're after.
>> - Dave
> For some reason, 'read-string' blocks when I don't specify a small enough 
> limit.

That's how I/O operations work.  'read-string' blocks until the end of
file.  Guess I misunderstood what you're after.

- Dave

reply via email to

[Prev in Thread] Current Thread [Next in Thread]