Pipes and custom streams¶
The Pipe class can be used to provide custom streams for the ACSE and DIMSE services.
A separate thread must be used to feed a Pipe (to supply a custom reading stream) or to sink data from a Pipe (to provide a custom writing stream).
Pipe: public imebra::BaseStreamInput, public imebra::BaseStreamOutput¶
A Pipe can be used to push and pull data to/from an Imebra codec.
This is useful when an Imebra codec must be used with a data source or a data sink not supported by the library (e.g. a TLS stream).
In order to allow Imebra to read data from a custom data source:
- allocate a Pipe class and use it as parameter for the StreamReader needed by the codec
- from a secondary thread feed the data to the data source by calling feed()
In order to allow Imebra to write data to a custom data source:
- allocate a Pipe class and use it as parameter for the StreamWriter needed by the codec
- from a secondary thread read the data to feed to the data sink by calling sink()
circularBufferSize: the size of the buffer that stores the data fed to the Pipe until it is fetched
feed(const ReadMemory &buffer)¶
buffer: the data to copy into the Pipe’s buffer
- the number of bytes read from the pipe, which may be less than the buffer’s size
buffer: a buffer that will contain the read data. The method will try to read as many bytes as the buffer size
close(unsigned int timeoutMilliseconds)¶
Subsequent read and write operations will fail by throwing the exception StreamClosedError.
timeoutMilliseconds: the maximum time to wait until the internal buffer is empty, in milliseconds