Help us shape the future of Go! Take the 2026 Go Developer Survey

channel

package
v0.4.13 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: BSD-3-Clause Imports: 7 Imported by: 2

Documentation

Overview

Package channel provides implementations of the chirp.Channel interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Direct

func Direct() (A, B chirp.Channel)

Direct constructs a connected pair of in-memory channels that pass packets directly without encoding into binary. Packets sent to A are received by B and vice versa.

func NetConn added in v0.1.3

func NetConn(c chirp.Channel) net.Conn

NetConn returns the net.Conn impementation underlying c, if one is available, or else nil. If c implements NetConner its corresponding method will be called to locate a connection. If c == nil, NetConn reports nil.

The chirp.Channel retains ownership of any net.Conn that is returned. Note that sending or receiving data, or otherwise changing the state of the resulting connection may invalidate assumptions of the channel that uses it.

Types

type IOChannel

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

An IOChannel sends and receives packets on a reader and a writer.

func IO

func IO(r io.Reader, wc io.WriteCloser) IOChannel

IO constructs a channel that receives from r and sends to wc.

func (IOChannel) Close

func (c IOChannel) Close() error

Close implements a method of the chirp.Channel interface.

func (IOChannel) NetConn added in v0.1.3

func (c IOChannel) NetConn() net.Conn

NetConn implements the optional NetConner interface. It returns a non-nil value if c was constructed with a net.Conn as its writer.

func (IOChannel) Recv

func (c IOChannel) Recv() (chirp.Packet, error)

Recv implements a method of the chirp.Channel interface.

func (IOChannel) Send

func (c IOChannel) Send(pkt chirp.Packet) error

Send implements a method of the chirp.Channel interface.

type NetConner added in v0.1.3

type NetConner interface {
	NetConn() net.Conn
}

NetConner is an optional interface that a chirp.Channel may implement to expose an underlying net.Conn used by its implementation. The method should report nil if its receiver does not have a net.Conn.

type Pipe added in v0.4.5

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

A Pipe implements the chirp.Channel interface around an os.Pipe.

func ConnectPipe added in v0.4.5

func ConnectPipe(r, w *os.File) *Pipe

ConnectPipe constructs a new Pipe wrapping the specified files.

func NewPipe added in v0.4.10

func NewPipe() (A, B *Pipe, _ error)

NewPipe establishes a connected pair of os.Pipe for a pair of peers, and returns Pipe values wrapping them. Sends to A are received by B and vice versa. Each call to NewPipe returns a distinct pair of pipes.

func (*Pipe) Close added in v0.4.10

func (c *Pipe) Close() error

Close implements part of the chirp.Channel interface.

func (*Pipe) Files added in v0.4.10

func (c *Pipe) Files() (r, w *os.File)

Files returns the underlying os.File values used by c.

func (*Pipe) Recv added in v0.4.10

func (c *Pipe) Recv() (chirp.Packet, error)

Recv implements part of the chirp.Channel interface.

func (*Pipe) Send added in v0.4.10

func (c *Pipe) Send(pkt chirp.Packet) error

Send implements part of the chirp.Channel interface.

Jump to

Keyboard shortcuts

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