[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: uniform-array-read!
From: |
William Xu |
Subject: |
Re: uniform-array-read! |
Date: |
Tue, 31 Jan 2006 22:54:58 +0800 |
User-agent: |
Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux) |
address@hidden (Ludovic Courtès) writes:
> William Xu <address@hidden> writes:
>
>> Is the following the correct way of using `uniform-array-read!'? Seems
>> it simply hangs there..
>>
>> (let ((ar (make-uniform-array #\nul length)))
>> (uniform-array-read! ar sockfd))
>
> In your example, it can very well be hanging because there is nothing to
> read from SOCKFD (e.g., it's making a blocking `read' system call
> beneath).
Ooh, that was only partial of the codes. Actually i've also written the
codes in C first to make sure we could *read*.
> Using Guile 1.7:
Not in debian yet.. Guile 1.6.7 here.
> guile> (define a (make-uniform-array #\nul 10))
> guile> (uniform-array-read! a (open-input-string (string #\001 #\002
> #\003)))
> 3
> guile> a
> #s8(1 2 3 32 51 10 -102 96 48 10)
> guile>
>
> IOW, it seems to work fine --- except that:
>
> 1. The array is not properly initialized;
It is.
> 2. The result is not a string as one would expect from the Guile 1.6
> manual[*] (in fact it could hardly be a string since internally
> strings may not contain null characters AFAIK).
What is that "result"? I noticed that in your example,
guile> (uniform-array-read! a (open-input-string (string #\001 #\002 #\003)))
The second argument for uniform-array-read! is a string. In my codes, i
tried to read binary data, precisely, a network packet. Does this
matter?
[...]
--
William