guile-devel
[Top][All Lists]
Advanced

[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: Fri, 13 Nov 2015 15:45:47 -0500

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



reply via email to

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