Go to main content

STREAMS Programming Guide

Exit Print View

Updated: November 2020
 
 

STREAMS Interfaces

The stream head provides the interface between the stream and an application program. After a stream is opened, STREAMS-related system calls enable a user process to insert and delete (push and pop) modules. The user process can then communicate with and control the operation of the stream head, modules, and drivers. The stream head handles most of the system calls so that the related processing need not be incorporated in a module or driver.

STREAMS System Calls

The basic STREAMS-related system calls are described in the following list:

  • open(2) – Opens a stream

  • close(2) – Closes a stream

  • read(2) – Reads data from a stream

  • write(2) – Writes data to a stream

  • ioctl(2) – Controls a stream

  • getmsg(2) – Receives a message at the stream head

  • getpmsg(2) – Receives a priority message at the stream head

  • putmsg(2) – Sends a message downstream

  • putpmsg(2) – Sends a priority message downstream

  • poll(2) – Identifies files on which a user can send or receive messages, or on which certain events have occurred (not restricted to STREAMS, although historically it was)

  • pipe(2) – Creates a bidirectional channel that provides a communication path between multiple processes


Note - Sections 1, 2, 3, 7, and 9 of the online manual pages (man pages) contain all the STREAMS information.

Action Summary

The open() system call recognizes a STREAMS special file and creates a stream to the specified driver.A user process can receive and send data on STREAMS files using read() and write() in the same way as with character files. ioctl() lets users perform functions specific to a particular device. STREAMS ioctl commands such as streamio support a variety of functions to access and control streams. The final close() on a stream dismantles it. For more information, see the open(2), read(2), ioctl(2), write(2), ioctl(2), streamio(4I), and close(2) man pages.

The poll() system call provides a mechanism for multiplexing input/output over a set of file descriptors that reference open files. putmsg() and getmsg() send and receive STREAMS messages, and can act on STREAMS modules and drivers through a service interface. For more information, see the poll(2), putmsg(2) and getmsg(2) man pages.