Binary output ports can be created with the procedures below.
Return two values: a binary output port and a procedure. The latter should be called with zero arguments to obtain a bytevector containing the data accumulated by the port, as illustrated below.
(call-with-values (lambda () (open-bytevector-output-port)) (lambda (port get-bytevector) (display "hello" port) (get-bytevector))) ⇒ #vu8(104 101 108 108 111)
The transcoder argument is currently not supported.
Return a new custom binary output port named id (a string) whose
output is sunk by invoking write! and passing it a bytevector, an
index where bytes should be read from this bytevector, and the number of
bytes to be “written”. The
write! procedure must return an
integer indicating the number of bytes actually written; when it is
0 as the number of bytes to write, it should behave as
though an end-of-file was sent to the byte sink.
The other arguments are as for
Writing to a binary output port can be done using the following procedures:
Write octet, an integer in the 0–255 range, to port, a binary output port.
Write the contents of bv to port, optionally starting at index start and limiting to count octets.