Plasma GitLab Archive
Projects Blog Knowledge

Class Netchannels.pipe


class pipe : ?conv:Netbuffer.t -> bool -> Netbuffer.t -> unit -> unit -> io_obj_channel
A pipe has two internal buffers (realized by Netbuffer). The output methods of the class write to the incoming buffer. When new data are appended to the incoming buffer, the conversion function conv is called; the arguments are the incoming buffer and the outgoing buffer. The conversion function must convert the data available in the incoming buffer and append the result to the outgoing buffer. Finally, the input methods of the class return the data found in the outgoing buffer.

The conversion function is called as follows: conv incoming_buffer at_eof outgoing_buffer

The conversion function is allowed to do nothing if the incoming data are not complete enough to be converted. It is also allowed to convert only the beginning of the incoming buffer.

If the outgoing buffer is empty, the input methods will raise Buffer_underrun.

If close_out is invoked, the end of the data stream will be recorded. In this case, the conversion function is called with at_eof = true, and it is expected that this function converts the whole data found in the incoming buffer.

close_in implies close_out.

The conversion function may raise exceptions. The exceptions will fall through to the caller of the input methods. (The output methods and close_in, close_out never fail because of such exceptions.)

The default conversion function copies everything from the incoming buffer to the outgoing buffer without modification.


This web site is published by Informatikbüro Gerd Stolpmann
Powered by Caml