Plasma GitLab Archive
Projects Blog Knowledge

Class type Netchannels.rec_out_channel


class type rec_out_channel = object .. end
Recommended output class type for library interoperability.

Description

This class type is defined in "Basic I/O class types" as collaborative effort of several library creators.

method output : string -> int -> int -> int
Takes octets from the string and writes them into the channel. The first int argument is the position of the substring, and the second int argument is the length of the substring where the data can be found. The method returns the number of octets actually written.

The implementation may choose to collect written octets in a buffer before they actually delivered to the underlying resource.

When the channel is non-blocking, and there are currently no bytes to write, the number 0 will be returned. This has been changed in ocamlnet-0.97! In previous releases this behaviour was undefined.

When the channel is closed, the exception Closed_channel will be raised if an ocamlnet implementation is used. For implementations of other libraries there is no standard for this case.

method flush : unit -> unit
If there is a write buffer, it will be flushed. Otherwise, nothing happens
method close_out : unit -> unit
Flushes the buffer, if any, and closes the channel for output.

When the channel is already closed, this is a no-op.

Error policy: Usually errors are logged to Netlog but not passed back to the caller. It is more important to ensure that the underlying resources are released than to report all issues to the caller. If a stricter error policy is required, users should call flush first. Implementations may nevertheless raise exceptions in close_out, especially in cases when the channel is seriously corrupted (e.g. the descriptor is invalid), or to report special user conditions.

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