[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fri, 03 Feb 2006 12:46:20 +0800
Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)
William Xu <address@hidden> writes:
> Alan Bram <address@hidden> writes:
>> | (define read-network-byte
>> | (lambda (port)
>> | (let ((v (make-uniform-array #\nul 1)))
> when array size is 1, it works. But if i set it to 3, for instance. Then
> it'll still block..
>> | (uniform-array-read! v port)
>> | (uniform-vector-ref v 0))))
> And i made the following workaround, using `recv!'. At least it works as
> (define (qq-read-binary-list sock length)
> "Read at most LENGTH bytes from SOCK. Return a list of integers."
> (let* ((buf (make-string length #\ ))
> (count (recv! sock buf)))
> (if (> count 0) ; we have read something.
> (string->list (substring buf 0 count)))
Oh, sorry. A minor mistake in the code. Here's updated,
(define (qq-read-list sock length)
"Read at most LENGTH bytes. Return a list of integers."
(let* ((buf (make-string length #\ ))
(count (recv! sock buf)))
(if (> count 0) ; we have read something.
(string->list (substring buf 0 count))))))
Re: uniform-array-read!, Marius Vollmer, 2006/02/11