net

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2015 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChanToWriter added in v0.6.1

func ChanToWriter(writer io.Writer, stream <-chan []byte) error

ChanToWriter dumps all content from a given chan to a writer until the chan is closed.

func ReaderToChan added in v0.6.1

func ReaderToChan(stream chan<- []byte, reader io.Reader) error

ReaderToChan dumps all content from a given reader to a chan by constantly reading it until EOF.

Types

type Address

type Address interface {
	IP() net.IP        // IP of this Address
	Domain() string    // Domain of this Address
	Port() uint16      // Port of this Address
	PortBytes() []byte // Port in bytes, network byte order

	IsIPv4() bool   // True if this Address is an IPv4 address
	IsIPv6() bool   // True if this Address is an IPv6 address
	IsDomain() bool // True if this Address is an domain address

	String() string // String representation of this Address
}

Address represents a network address to be communicated with. It may be an IP address or domain address, not both. This interface doesn't resolve IP address for a given domain.

func DomainAddress

func DomainAddress(domain string, port uint16) Address

DomainAddress creates an Address with given domain and port.

func IPAddress

func IPAddress(ip []byte, port uint16) Address

IPAddress creates an Address with given IP and port.

type Destination

type Destination interface {
	Network() string  // Protocol of communication (tcp / udp)
	Address() Address // Address of destination
	String() string   // String representation of the destination

	IsTCP() bool // True if destination is reachable via TCP
	IsUDP() bool // True if destination is reachable via UDP
}

Destination represents a network destination including address and protocol (tcp / udp).

func NewTCPDestination added in v0.6.1

func NewTCPDestination(address Address) Destination

NewTCPDestination creates a TCP destination with given address

func NewUDPDestination added in v0.6.1

func NewUDPDestination(address Address) Destination

NewUDPDestination creates a UDP destination with given address

type DomainAddressImpl added in v0.6.1

type DomainAddressImpl struct {
	PortAddress
	// contains filtered or unexported fields
}

func (DomainAddressImpl) Domain added in v0.6.1

func (addr DomainAddressImpl) Domain() string

func (DomainAddressImpl) IP added in v0.6.1

func (addr DomainAddressImpl) IP() net.IP

func (DomainAddressImpl) IsDomain added in v0.6.1

func (addr DomainAddressImpl) IsDomain() bool

func (DomainAddressImpl) IsIPv4 added in v0.6.1

func (addr DomainAddressImpl) IsIPv4() bool

func (DomainAddressImpl) IsIPv6 added in v0.6.1

func (addr DomainAddressImpl) IsIPv6() bool

func (DomainAddressImpl) String added in v0.6.1

func (addr DomainAddressImpl) String() string

type IPv4Address added in v0.6.1

type IPv4Address struct {
	PortAddress
	// contains filtered or unexported fields
}

func (IPv4Address) Domain added in v0.6.1

func (addr IPv4Address) Domain() string

func (IPv4Address) IP added in v0.6.1

func (addr IPv4Address) IP() net.IP

func (IPv4Address) IsDomain added in v0.6.1

func (addr IPv4Address) IsDomain() bool

func (IPv4Address) IsIPv4 added in v0.6.1

func (addr IPv4Address) IsIPv4() bool

func (IPv4Address) IsIPv6 added in v0.6.1

func (addr IPv4Address) IsIPv6() bool

func (IPv4Address) String added in v0.6.1

func (addr IPv4Address) String() string

type IPv6Address added in v0.6.1

type IPv6Address struct {
	PortAddress
	// contains filtered or unexported fields
}

func (IPv6Address) Domain added in v0.6.1

func (addr IPv6Address) Domain() string

func (IPv6Address) IP added in v0.6.1

func (addr IPv6Address) IP() net.IP

func (IPv6Address) IsDomain added in v0.6.1

func (addr IPv6Address) IsDomain() bool

func (IPv6Address) IsIPv4 added in v0.6.1

func (addr IPv6Address) IsIPv4() bool

func (IPv6Address) IsIPv6 added in v0.6.1

func (addr IPv6Address) IsIPv6() bool

func (IPv6Address) String added in v0.6.1

func (addr IPv6Address) String() string

type Packet added in v0.6.1

type Packet interface {
	Destination() Destination
	Chunk() []byte // First chunk of this commnunication
	MoreChunks() bool
}

type PortAddress added in v0.6.1

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

func (PortAddress) Port added in v0.6.1

func (addr PortAddress) Port() uint16

func (PortAddress) PortBytes added in v0.6.1

func (addr PortAddress) PortBytes() []byte

type TCPDestination

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

func (TCPDestination) Address added in v0.6.1

func (dest TCPDestination) Address() Address

func (TCPDestination) IsTCP added in v0.6.1

func (dest TCPDestination) IsTCP() bool

func (TCPDestination) IsUDP added in v0.6.1

func (dest TCPDestination) IsUDP() bool

func (TCPDestination) Network added in v0.6.1

func (dest TCPDestination) Network() string

func (TCPDestination) String added in v0.6.1

func (dest TCPDestination) String() string

type TCPPacket added in v0.6.1

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

func NewTCPPacket added in v0.6.1

func NewTCPPacket(dest Destination) *TCPPacket

func (*TCPPacket) Chunk added in v0.6.1

func (packet *TCPPacket) Chunk() []byte

func (TCPPacket) Destination added in v0.6.1

func (base TCPPacket) Destination() Destination

func (*TCPPacket) MoreChunks added in v0.6.1

func (packet *TCPPacket) MoreChunks() bool

type TimeOutReader added in v0.6.1

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

func NewTimeOutReader added in v0.6.1

func NewTimeOutReader(timeout int, connection net.Conn) *TimeOutReader

func (*TimeOutReader) Read added in v0.6.1

func (reader *TimeOutReader) Read(p []byte) (n int, err error)

type UDPDestination

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

func (UDPDestination) Address added in v0.6.1

func (dest UDPDestination) Address() Address

func (UDPDestination) IsTCP added in v0.6.1

func (dest UDPDestination) IsTCP() bool

func (UDPDestination) IsUDP added in v0.6.1

func (dest UDPDestination) IsUDP() bool

func (UDPDestination) Network added in v0.6.1

func (dest UDPDestination) Network() string

func (UDPDestination) String added in v0.6.1

func (dest UDPDestination) String() string

type UDPPacket added in v0.6.1

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

func NewUDPPacket added in v0.6.1

func NewUDPPacket(dest Destination, data []byte, token uint16) *UDPPacket

func (*UDPPacket) Chunk added in v0.6.1

func (packet *UDPPacket) Chunk() []byte

func (UDPPacket) Destination added in v0.6.1

func (base UDPPacket) Destination() Destination

func (*UDPPacket) MoreChunks added in v0.6.1

func (packet *UDPPacket) MoreChunks() bool

func (*UDPPacket) Token added in v0.6.2

func (packet *UDPPacket) Token() uint16

Jump to

Keyboard shortcuts

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