V7/usr/man/man4/pk.4
.TH PK 4 local
.SH NAME
pk \- packet driver
.SH DESCRIPTION
The packet driver
implements a full-duplex end-to-end flow control strategy
for machine-to-machine communication.
Packet driver protocol is established by
calling
.IR pkon (2)
with a character device file descriptor and
a desired packet size in bytes.
The packet size must be a power of 2,
.RI 32\(<= size \(<=4096.
The file descriptor
must represent an 8-bit data path.
This is normally obtained by setting
the device in raw mode
(see
.IR ioctl (2)).
.PP
The actual packet size, which may be smaller than
the desired packet size, is arrived at by
negotiation with the packet driver
at the remote end of the data link.
.PP
The packet driver maintains two
data areas
for incoming and outgoing packets.
The output area is needed to implement retransmission
on errors,
and
arriving packets are queued in the input area.
Data arriving for a file not open for reading is discarded.
Initially the size of both areas is set
to two packets.
.PP
It is not necessary that reads and writes
be multiples of the packet size although
there is less system overhead if they are.
Read operations return the maximum amount of data
available from the input area up to the
number of bytes specified in the system call.
The buffer sizes in write operations
are not normally transmitted across the link.
However, writes of zero length are treated specially
and are reflected at the remote end as a
zero-length read.
This facilitates marking the serial byte stream,
usually for delimiting files.
.PP
When one side of a packet driver link is shut down by
.IR close (2) or
.I pkoff
(see
.IR pkon (2)),
.IR read (2)
on the other side will return 0, and
.I write
on the other side
will raise a SIGPIPE signal.
.SH "SEE ALSO"
pkon(2), pkopen(3)