netutil

package
v3.0.7+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2019 License: BSD-3-Clause, GPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BUFFERSIZE = 8 * 1024
	BufferPool = sync.Pool{
		New: func() interface{} {
			return make([]byte, BUFFERSIZE)
		},
	}
)
View Source
var (
	ErrFalseDialer = errors.New("not allow to dail")
)

Functions

func CopyLink(dst, src io.ReadWriteCloser)

func EchoServer

func EchoServer(wg *sync.WaitGroup)

func ListenAndServe

func ListenAndServe(network, address string, handler func(net.Conn)) (err error)

Types

type ConnCreator

type ConnCreator interface {
	CreateConn() (net.Conn, error)
}

func NewTcpConnCreator

func NewTcpConnCreator(net, addr string) (creator ConnCreator)

type Dialer

type Dialer interface {
	Dial(string, string) (net.Conn, error)
}

type FalseDialer

type FalseDialer struct {
}

func (*FalseDialer) Dial

func (fd *FalseDialer) Dial(network, address string) (net.Conn, error)

func (*FalseDialer) DialTimeout

func (fd *FalseDialer) DialTimeout(network, address string, timeout time.Duration) (net.Conn, error)

type Tcp4Dialer

type Tcp4Dialer struct {
}

func (*Tcp4Dialer) Dial

func (td *Tcp4Dialer) Dial(network, address string) (net.Conn, error)

func (*Tcp4Dialer) DialTimeout

func (td *Tcp4Dialer) DialTimeout(network, address string, timeout time.Duration) (net.Conn, error)

type TcpConnCreator

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

func (*TcpConnCreator) CreateConn

func (tcc *TcpConnCreator) CreateConn() (conn net.Conn, err error)

type TcpDialer

type TcpDialer struct {
}

func (*TcpDialer) Dial

func (td *TcpDialer) Dial(network, address string) (net.Conn, error)

func (*TcpDialer) DialTimeout

func (td *TcpDialer) DialTimeout(network, address string, timeout time.Duration) (net.Conn, error)

type TimeoutDialer

type TimeoutDialer interface {
	Dialer
	DialTimeout(string, string, time.Duration) (net.Conn, error)
}
var DefaultFalseDialer TimeoutDialer = &FalseDialer{}
var DefaultTcp4Dialer TimeoutDialer = &Tcp4Dialer{}
var DefaultTcpDialer TimeoutDialer = &TcpDialer{}

Jump to

Keyboard shortcuts

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