transports

package
v0.0.0-...-c0ffc74 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2015 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package transports implements Generic interfaces for telehash transports

Transports must implement the Config and Transport interfaces. Endpoints are responsible for actually managing the transports.

e3x.New(keys, udp.Config{})

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidAddr = errors.New("invalid address")

Functions

func DecodeAddr

func DecodeAddr(p []byte) (net.Addr, error)

DecodeAddr will decode an address from JSON. ErrInvalidAddr is returned when the address could not be decoded.

func EncodeAddr

func EncodeAddr(a net.Addr) ([]byte, error)

func EqualAddr

func EqualAddr(a, b net.Addr) bool

func RegisterAddr

func RegisterAddr(typ AddrMarshaler)

RegisterAddr registers a marshalable address type. Addr types that are expected to be communicated through telehash must be registered here.

func RegisterResolver

func RegisterResolver(network string, resolver func(addr string) (net.Addr, error))

func ResolveAddr

func ResolveAddr(network, addr string) (net.Addr, error)

Types

type AddrEqualer

type AddrEqualer interface {
	Equal(other net.Addr) bool
}

type AddrMarshaler

type AddrMarshaler interface {
	net.Addr
	json.Marshaler
	json.Unmarshaler
}

type Config

type Config interface {
	Open() (Transport, error)
}

Config must be implemented by transport packages

type Transport

type Transport interface {

	// Addrs returns all the known addresses this transport is reachable at.
	Addrs() []net.Addr

	// Dial will open a new connection to addr.
	// io.EOF is returned when the transport is closed.
	// ErrInvalidAddr must be returned when the addr is
	// not suppoorted by the transport.
	Dial(addr net.Addr) (net.Conn, error)

	// Accept will accept the next incomming connection.
	// io.EOF is returned when the transport is closed.
	Accept() (c net.Conn, err error)

	// Close closes the transport.
	Close() error
}

Transport is an opened transport. This interface is used internally by E3X.

Directories

Path Synopsis
Package dgram provides a wrapper for datagram based transports like UDP.
Package dgram provides a wrapper for datagram based transports like UDP.
Package inproc implements the in-process transport
Package inproc implements the in-process transport
Package mux implements a transport muxer.
Package mux implements a transport muxer.
Package nat privides NAT port mapping for transports that support it.
Package nat privides NAT port mapping for transports that support it.
Package tcp implements the TCP transport.
Package tcp implements the TCP transport.
Package udp implements the UDP transport.
Package udp implements the UDP transport.
Package unix implements the UNIX domain sockets transport.
Package unix implements the UNIX domain sockets transport.

Jump to

Keyboard shortcuts

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