multiplex

package module
v0.2.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2017 License: MIT Imports: 11 Imported by: 0

README

go-multiplex

A super simple stream muxing library compatible with multiplex

Usage

mplex := multiplex.NewMultiplex(mysocket)

s, _ := mplex.NewStream()
s.Write([]byte("Hello World!")
s.Close()

os, _ := mplex.Accept()
// echo back everything received
io.Copy(os, os)

Documentation

Index

Constants

View Source
const (
	NewStream = 0
	Message   = 1
	Close     = 3
	Reset     = 5
)

+1 for initiator

Variables

View Source
var ErrShutdown = errors.New("session shut down")
View Source
var MaxMessageSize = 1 << 20

Functions

This section is empty.

Types

type Multiplex

type Multiplex struct {
	// contains filtered or unexported fields
}

func NewMultiplex

func NewMultiplex(con net.Conn, initiator bool) *Multiplex

func (*Multiplex) Accept

func (m *Multiplex) Accept() (*Stream, error)

func (*Multiplex) Close

func (mp *Multiplex) Close() error

func (*Multiplex) IsClosed

func (mp *Multiplex) IsClosed() bool

func (*Multiplex) NewNamedStream

func (mp *Multiplex) NewNamedStream(name string) (*Stream, error)

func (*Multiplex) NewStream

func (mp *Multiplex) NewStream() (*Stream, error)

type Stream

type Stream struct {
	// contains filtered or unexported fields
}

func (*Stream) Close

func (s *Stream) Close() error

func (*Stream) Name

func (s *Stream) Name() string

func (*Stream) Read

func (s *Stream) Read(b []byte) (int, error)

func (*Stream) Reset added in v0.2.11

func (s *Stream) Reset() error

func (*Stream) SetDeadline added in v0.1.0

func (s *Stream) SetDeadline(t time.Time) error

func (*Stream) SetReadDeadline added in v0.1.0

func (s *Stream) SetReadDeadline(t time.Time) error

func (*Stream) SetWriteDeadline added in v0.1.0

func (s *Stream) SetWriteDeadline(t time.Time) error

func (*Stream) Write

func (s *Stream) Write(b []byte) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL