utp

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2015 License: MIT, MIT Imports: 16 Imported by: 0

README

utp

μTP (Micro Transport Protocol) implementation

Build status Build Status GoDoc

http://www.bittorrent.org/beps/bep_0029.html

Installation

go get github.com/h2so5/utp

Debug Log

Use GO_UTP_LOGGING to show debug logs.

GO_UTP_LOGGING=0 go test  <- default, no logging
GO_UTP_LOGGING=1 go test
GO_UTP_LOGGING=2 go test
GO_UTP_LOGGING=3 go test
GO_UTP_LOGGING=4 go test  <- most verbose

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addr added in v0.3.4

type Addr struct {
	net.Addr
}

Addr represents the address of a UTP end point.

func ResolveAddr added in v0.3.4

func ResolveAddr(n, addr string) (*Addr, error)

ResolveAddr parses addr as a UTP address of the form "host:port" or "[ipv6-host%zone]:port" and resolves a pair of domain name and port name on the network net, which must be "utp", "utp4" or "utp6". A literal address or host name for IPv6 must be enclosed in square brackets, as in "[::1]:80", "[ipv6-host]:http" or "[ipv6-host%zone]:80".

func (Addr) Network added in v0.3.4

func (a Addr) Network() string

Network returns the address's network name, "utp".

type Conn added in v0.3.4

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

Conn is an implementation of the Conn interface for UTP network connections.

func DialUTP

func DialUTP(n string, laddr, raddr *Addr) (*Conn, error)

DialUTP connects to the remote address raddr on the network net, which must be "utp", "utp4", or "utp6". If laddr is not nil, it is used as the local address for the connection.

func DialUTPTimeout

func DialUTPTimeout(n string, laddr, raddr *Addr, timeout time.Duration) (*Conn, error)

DialUTPTimeout acts like Dial but takes a timeout. The timeout includes name resolution, if required.

func (*Conn) Close added in v0.3.4

func (c *Conn) Close() error

Close closes the connection.

func (*Conn) LocalAddr added in v0.3.4

func (c *Conn) LocalAddr() net.Addr

LocalAddr returns the local network address.

func (*Conn) Read added in v0.3.4

func (c *Conn) Read(b []byte) (int, error)

Read implements the Conn Read method.

func (*Conn) RemoteAddr added in v0.3.4

func (c *Conn) RemoteAddr() net.Addr

RemoteAddr returns the remote network address.

func (*Conn) SetDeadline added in v0.3.4

func (c *Conn) SetDeadline(t time.Time) error

SetDeadline implements the Conn SetDeadline method.

func (*Conn) SetKeepAlive added in v0.3.4

func (c *Conn) SetKeepAlive(d time.Duration) error

SetKeepAlive sets the keepalive interval associated with the connection.

func (*Conn) SetReadDeadline added in v0.3.4

func (c *Conn) SetReadDeadline(t time.Time) error

SetReadDeadline implements the Conn SetReadDeadline method.

func (*Conn) SetWriteDeadline added in v0.3.4

func (c *Conn) SetWriteDeadline(t time.Time) error

SetWriteDeadline implements the Conn SetWriteDeadline method.

func (*Conn) Write added in v0.3.4

func (c *Conn) Write(b []byte) (int, error)

Write implements the Conn Write method.

type Dialer

type Dialer struct {
	// Timeout is the maximum amount of time a dial will wait for
	// a connect to complete. If Deadline is also set, it may fail
	// earlier.
	//
	// The default is no timeout.
	//
	// With or without a timeout, the operating system may impose
	// its own earlier timeout. For instance, TCP timeouts are
	// often around 3 minutes.
	Timeout time.Duration

	// LocalAddr is the local address to use when dialing an
	// address. The address must be of a compatible type for the
	// network being dialed.
	// If nil, a local address is automatically chosen.
	LocalAddr net.Addr
}

A Dialer contains options for connecting to an address.

The zero value for each field is equivalent to dialing without that option. Dialing with the zero value of Dialer is therefore equivalent to just calling the Dial function.

func (*Dialer) Dial

func (d *Dialer) Dial(n, addr string) (*Conn, error)

Dial connects to the address on the named network.

See func Dial for a description of the network and address parameters.

type Listener added in v0.3.4

type Listener struct {
	// RawConn represents an out-of-band connection.
	// This allows a single socket to handle multiple protocols.
	RawConn net.PacketConn
	// contains filtered or unexported fields
}

Listener is a UTP network listener. Clients should typically use variables of type Listener instead of assuming UTP.

func Listen

func Listen(n string, laddr *Addr) (*Listener, error)

Listen announces on the UTP address laddr and returns a UTP listener. Net must be "utp", "utp4", or "utp6". If laddr has a port of 0, ListenUTP will choose an available port. The caller can use the Addr method of Listener to retrieve the chosen address.

func (*Listener) Accept added in v0.3.4

func (l *Listener) Accept() (net.Conn, error)

Accept implements the Accept method in the Listener interface; it waits for the next call and returns a generic Conn.

func (*Listener) AcceptUTP added in v0.3.4

func (l *Listener) AcceptUTP() (*Conn, error)

AcceptUTP accepts the next incoming call and returns the new connection.

func (*Listener) Addr added in v0.3.4

func (l *Listener) Addr() net.Addr

Addr returns the listener's network address, a *Addr.

func (*Listener) Close added in v0.3.4

func (l *Listener) Close() error

Close stops listening on the UTP address. Already Accepted connections are not closed.

func (*Listener) SetDeadline added in v0.3.4

func (l *Listener) SetDeadline(t time.Time) error

SetDeadline sets the deadline associated with the listener. A zero time value disables the deadline.

Directories

Path Synopsis
package ucat provides an implementation of netcat using the go utp package.
package ucat provides an implementation of netcat using the go utp package.

Jump to

Keyboard shortcuts

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