Documentation ¶
Overview ¶
Package bsda provides message framing on top of ordered reliable byte streams.
The format is as follows:
Byte Stream Datagram Adaptation No. 1 (BSDA-1) ============================================== Stream: Zero or more frames Frame: 4 ui Data Length ... Data That is, each frame is a unsigned 32-bit integer indicating the data length, followed by that many bytes of data. All fields are little endian.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrOversizeFrame = fmt.Errorf("received frame in excess of permitted size")
var ErrUnidirectional = fmt.Errorf("unidirectional stream")
Functions ¶
This section is empty.
Types ¶
type FrameReadWriter ¶
type FrameReadWriter interface { FrameReader FrameWriter }
type FrameReadWriterCloser ¶
type FrameReadWriterCloser interface { FrameReadWriter Close() error }
type FrameReader ¶
type FrameWriter ¶
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Bidirectional BSDA message stream.
func New ¶
func New(stream io.ReadWriter) *Stream
Instantiates a new bidirectional BSDA message stream which provides framing on top of an underlying bytestream.
func NewReader ¶
Instantiates a new unidirectional BSDA message stream which provides framing on top of an underlying bytestream.
func NewWriter ¶
Instantiates a new unidirectional BSDA message stream which provides framing on top of an underlying bytestream.
func (*Stream) Close ¶
Close the stream. If the underlying writer supports the io.Closer interface, it is closed as well.
func (*Stream) ReadFrame ¶
Read a single frame. Underlying I/O errors are passed through.
Returns ErrOversizeFrame if the received frame exceeded MaxRxFrameSize. Calling this method again will skip such a frame's body and receive the next frame.
Do not call this method concurrently.
func (*Stream) WriteFrame ¶
Write a single frame. Underlying I/O errors are passed through.
Unlike ReadFrame, this method may be called concurrently.