Hello
I can't find out how to read bytes from a device file:
(define urandom-port (open-input-file "/dev/urandom")) urandom-port
#<input-port #2 "/dev/urandom">
(read-byte urandom-port)
*** ERROR IN ##read-byte -- Invalid argument (read-char '#<input-port #2 "/dev/urandom">) 1>
btw note that the error message mentions read-char instead of read-byte
(read-char urandom-port)
*** ERROR IN (console)@5.1 -- Invalid argument (read-char '#<input-port #2 "/dev/urandom">) 1>
(input-port-byte-position urandom-port)
*** ERROR IN (console)@6.1 -- Unknown error (input-port-byte-position '#<input-port #2 "/dev/urandom">) 1>
whereas with a normal file:
(define urandom-port (open-input-file "chj.scm")) urandom-port
#<input-port #3 "/home/chris/schemedevelopment/gambit/chj.scm">
(read-byte urandom-port)
10
(read-char urandom-port)
#(
(input-port-byte-position urandom-port)
0
(read-byte urandom-port)
100
(input-port-byte-position urandom-port)
0
(read-byte urandom-port)
101
(input-port-byte-position urandom-port)
0
(but isn't it strange that input-port-byte-position doesn't advance?)
Thanks for your help Christian.
Afficher les réponses par date