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: