multiplex

package
v0.4.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2016 License: MIT Imports: 7 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()

mplex.Serve(func(s *multiplex.Stream) {
	// echo back everything received
	io.Copy(s, s)
})

Documentation

Index

Constants

View Source
const (
	NewStream = iota
	Receiver
	Initiator
	Unknown
	Close
)

Variables

This section is empty.

Functions

func DecodeVarint

func DecodeVarint(r *bufio.Reader) (x uint64, n int, err error)

func EncodeVarint

func EncodeVarint(x uint64) []byte

Types

type Multiplex

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

func NewMultiplex

func NewMultiplex(con io.ReadWriteCloser, 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

func (*Multiplex) NewStream

func (mp *Multiplex) NewStream() *Stream

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) 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