NIO CommKit Host Interface Installation and System Administration Manual

6-16
Porting CommKit Applications To Release 4.x
Programmer-Level Compatibility
Some key points to note about read are listed below:
O_NODELAY - when reading from a character driver, a device with no data
returns a value of 0. When reading from a stream head, a device with no data
returns a value of -1 with errno set to EAGAIN.
LEVEL-D - if a STREAMS read call reads an URP level-D control code, it might
return a -1 error code, with errno set to EBADMSG. Level-D codes arrive as
M_PROTO messages. To read the control code, use the appropriate library
function in your application, for example, isdkleveld (refer to the isdkleveld
example later in this chapter).
FAIL - the read may fail because an error message such as an M_ERROR or an
M_HANGUP reaches the stream head.
write(2)
The write system call has changed. Some key points to note about write are
listed below:
BLOCKING - A STREAMS device issues a block error on a write call only if the
device cannot accept data due to flow-control directives issued by a lower level.
A write call usually returns immediately. (See also O_NODELAY).
O_NODELAY - A write call with the O_NODELAY flag set behaves very
differently when made to a STREAMS device. Most write calls to STREAMS
devices return immediately; usually, the O_NODELAY flag does not make a
difference. However, if the device cannot accept data and the O_NODELAY flag
is set, the write returns a -1 with errno set to AGAIN. If the device can only
accept part of the data, a write with O_NODELAY set might return less than the
requested amount of data.
LEVEL-D - You cannot write URP level-D codes with the write system call,
because the codes must be M_PROTO messages. To send URP level-D codes,
use the library function dkleveld. Refer to the dkleveld example later in this
chapter.
FAIL - A write call to a stream head fails if the stream receives an M_ERROR
message.