MAINSAIL STREAMS User's Guide, Chapter 12

previous   next   top   contents   index   framed top   this page unframed


12. Memory Streams: MEMSTR

Memory streams are used for two-way communication between coroutines. They are created in pairs with the stream MODULE MEMSTR. Both coroutines typically know that they are communicating with each other so that an understood communications protocol can be used.

Output to $openStream's stream s1 is read as input on s2, and output to s2 is read as input on s1. The Scheduler (see Chapter 8) ensures that the coroutines that read and write the streams are scheduled appropriately.

Memory streams are useful for serialized communication of text, octets, or storage units between two or more coroutines running in the same MAINSAIL process. They are a low-overhead simulation of the use of socket streams for interprocess communication. Closely coupled coroutines that share arbitrarily complex data structures should probably use semaphores instead of memory streams.

Memory streams do not have semantics normally associated with TTY streams: no echo occurs, there are no special keyboard interrupt characters, and there is no explicit flow control or baud rate.

There are no special bits, fields, or PROCEDUREs associated with memory streams. The $eos return means that the other end of the stream has been closed.

It is invalid to give a host name for a MEMSTR stream.


previous   next   top   contents   index   framed top   this page unframed

MAINSAIL STREAMS User's Guide, Chapter 12