mux

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2021 License: MIT Imports: 10 Imported by: 7

Documentation

Overview

Package mux implements a qmux session and channel API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

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

Channel is an implementation of the Channel interface that works with the Session class.

func (*Channel) Close

func (ch *Channel) Close() error

Close signals end of channel use. No data may be sent after this call.

func (*Channel) CloseWrite

func (ch *Channel) CloseWrite() error

CloseWrite signals the end of sending data. The other side may still send data

func (*Channel) ID

func (ch *Channel) ID() uint32

ID returns the unique identifier of this channel within the session

func (*Channel) Read

func (c *Channel) Read(data []byte) (n int, err error)

Read reads up to len(data) bytes from the channel.

func (*Channel) Write

func (ch *Channel) Write(data []byte) (n int, err error)

Write writes len(data) bytes to the channel.

type Listener

type Listener interface {
	// Close closes the listener.
	// Any blocked Accept operations will be unblocked and return errors.
	Close() error

	// Accept waits for and returns the next incoming session.
	Accept() (*Session, error)

	// Addr returns the listener's network address if available.
	Addr() net.Addr
}

A Listener is similar to a net.Listener but returns connections wrapped as mux sessions.

func ListenIO

func ListenIO(out io.WriteCloser, in io.ReadCloser) (Listener, error)

ListenIO returns an IOListener that gives a mux session based on seperate WriteCloser and ReadClosers.

func ListenStdio

func ListenStdio() (Listener, error)

ListenStdio is a convenience for calling ListenIO with Stdout and Stdin.

func ListenTCP

func ListenTCP(addr string) (Listener, error)

ListenTCP creates a TCP listener at the given address.

func ListenUnix

func ListenUnix(path string) (Listener, error)

ListenTCP creates a Unix domain socket listener at the given path.

func ListenWS

func ListenWS(addr string) (Listener, error)

ListenWS takes a TCP address and returns a Listener for a HTTP+WebSocket server listening on the given address.

func ListenerFrom

func ListenerFrom(l net.Listener) Listener

type Session

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

Session is a bi-directional channel muxing session on a given transport.

func DialIO

func DialIO(out io.WriteCloser, in io.ReadCloser) (*Session, error)

DialIO establishes a mux session using a WriterCloser and ReadCloser.

func DialStdio

func DialStdio() (*Session, error)

DialIO establishes a mux session using Stdout and Stdin.

func DialTCP

func DialTCP(addr string) (*Session, error)

DialTCP establishes a mux session via TCP connection.

func DialUnix

func DialUnix(path string) (*Session, error)

DialUnix establishes a mux session via Unix domain socket.

func DialWS

func DialWS(addr string) (*Session, error)

DialWS establishes a mux session via WebSocket connection. The address must be a host and port. Opening a WebSocket connection at a particular path is not supported.

func New

func New(t io.ReadWriteCloser) *Session

NewSession returns a session that runs over the given transport.

func (*Session) Accept

func (s *Session) Accept() (*Channel, error)

Accept waits for and returns the next incoming channel.

func (*Session) Close

func (s *Session) Close() error

Close closes the underlying transport.

func (*Session) Open

func (s *Session) Open(ctx context.Context) (*Channel, error)

Open establishes a new channel with the other end.

func (*Session) Wait

func (s *Session) Wait() error

Wait blocks until the transport has shut down, and returns the error causing the shutdown.

Directories

Path Synopsis
Package frame implements encoding and decoding of qmux message frames.
Package frame implements encoding and decoding of qmux message frames.

Jump to

Keyboard shortcuts

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