Plasma GitLab Archive
Projects Blog Knowledge

Class Netstream.sub_stream

class sub_stream : ?len:int -> ?delimiter:string -> in_obj_stream -> in_obj_stream
A sub stream is the part of the whole stream from the current position to an arbitrary other position that is determined by len and delimiter. len specifies the maximum length of the sub stream. delimiter is an arbitrary string that indicates the end of the sub stream (the delimiter is not part of the sub stream; i.e. the sub stream ends immediately before the delimiter).

While reading from the sub stream, not only the current position of the sub stream moves, but also the current position of the main stream. This means that it must be avoided to read data from the main stream while the sub stream is in use. The typical pattern is:

  • Read from the main stream until the beginning of a section is recognized
  • Create a sub stream at this point
  • Read from the sub stream until EOF
  • Continue reading the main stream. The next character of the main stream is exactly the character following the EOF of the sub stream

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