I'm getting bytes off the wire and attempting to write them to a port. I
have a check in place to verify that the pipe has free space but when I
attempt to reports that yes, there is space, and then it writes and fails
regardless and I'm not sure why. The following is a simplified version of
the code but it produces the same results as the live version.
I've dug through the docs on write-bytes-avail* and pipes and I'm
scratching my head. Any thoughts?
------- code
#lang racket
(define bstr (make-shared-bytes 509 5))
(define rx-pipe-size 16777216)
(define-values (rx-in rx-out) (make-pipe rx-pipe-size))
(define (room-in-rx-pipe? bstr)
(define avail (- rx-pipe-size (pipe-content-length rx-out)))
(displayln (format "space available: ~a" avail))
(<= (bytes-length bstr) avail))
(displayln (format "space available? ~a " (room-in-rx-pipe? bstr)))
(define num-bytes-written (write-bytes-avail* bstr rx-out))
(unless (eq? num-bytes-written (bytes-length bstr))
(displayln (format "rx buffer overflow. num-bytes-written ~a, expected ~a"
num-bytes-written (bytes-length bstr))))
(displayln "done")
-------- /code
The output is:
------- output
avail: 16777216
space available? #t
pipe content length: 0
rx buffer overflow. pipe content length: 15, written 15, expected 509
done
------- /output
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/racket-users/CAE8gKodhx-cZ75-WBb9qcqO9Aotq5ebDCiO6T33x%2BYK_RdCAkw%40mail.gmail.com.