package bytesrw
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha512=388858b0db210a62a16f56655746fdfadbc64b22c2abb5ed5a12b2872e4f8c34f045cdb953a5dda9b92f0003c7f9f34d70fa5b5bb19fd32fb6121bbaeb7ceba0
doc/bytesrw.unix/Bytesrw_unix/index.html
Module Bytesrw_unixSource
Blocking Unix file descriptor byte stream readers and writers.
val bytes_reader_of_fd :
?pos:Bytesrw.Bytes.Stream.pos ->
?slice_length:Bytesrw.Bytes.Slice.length ->
Unix.file_descr ->
Bytesrw.Bytes.Reader.tbytes_reader_of_fd fd reads bytes from the blocking fd with Unix.read and provides them as slices of maximal length slice_length (defaults to Bytesrw.Bytes.Slice.unix_io_buffer_size). Bytesrw.Bytes.Slice.eod is returned when Unix.read returns 0.
pos defaults to the fd position as determined by Unix.lseek. Reads are retried on Unix.error.EINTR but both this function and the resulting reader may raise Unix.Unix_error.
Note. The reader performs no ressource management. It is the client's duty to close the fd. It can be used on sockets.
val bytes_writer_of_fd :
?pos:Bytesrw.Bytes.Stream.pos ->
?slice_length:Bytesrw.Bytes.Slice.length ->
Unix.file_descr ->
Bytesrw.Bytes.Writer.tbytes_writer_of_fd fd writes bytes to the blocking fd using Unix.single_write. The hinted slice_length defaults to Bytesrw.Bytes.Slice.unix_io_buffer_size. Writing Bytesrw.Bytes.Slice.eod only terminates the writer, it makes no effect on fd, it only terminates the writer.
pos defaults to the fd position as determined by Unix.lseek. Writes are retried on Unix.error.EINTR but both this function and the resulting writer may raise Unix.Unix_error.
Note. The writer performs no ressource management. It is the client's duty to close the fd. It can be used on sockets but bytes_writer_of_socket_fd may be a better fit.
val bytes_writer_of_socket_fd :
?pos:Bytesrw.Bytes.Stream.pos ->
?slice_length:Bytesrw.Bytes.Slice.length ->
Unix.file_descr ->
Bytesrw.Bytes.Writer.tbytes_writer_of_socket_fd is like bytes_writer_of_fd except that when Bytesrw.Bytes.Slice.eod is written it calls Unix.shutdown with Unix.shutdown_command.SHUTDOWN_SEND and pos defaults to 0.