STREAMS Programming Guide

Exit Print View

Updated: July 2014
 
 

Message Components

All kernel-level input and output under STREAMS is based on messages. STREAMS messages are built in sets of three:

  • a message header structure (msgb(9S)) that identifies the message instance.

  • a data block structure (datab(9S)) points to the data of the message.

  • the data itself

Each data block and data pair can be referenced by one or more message headers. The objects passed between STREAMS modules are pointers to messages. Messages are sent through a stream by successive calls to the put procedure of each module or driver in the stream. Messages can exist as independent units, or on a linked list of messages called a message queue. STREAMS utility routines enable developers to manipulate messages and message queues.

All STREAMS messages are assigned message types to indicate how they will be used by modules and drivers and how they will be handled by the stream head. Message types are assigned by the stream head, driver, or module when the message is created. The stream head converts the system calls read, write, putmsg, and putpmsg into specified message types, and sends them downstream. It responds to other calls by copying the contents of certain message types that were sent upstream.