William Xu <[EMAIL PROTECTED]> writes: > Alan Bram <[EMAIL PROTECTED]> 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 > expected. > > (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. > (map > char->integer > (string->list (substring buf 0 count))) > lst)))
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. (map char->integer (string->list (substring buf 0 count)))))) -- William _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user