netgo

package module
v0.0.0-...-da4404f Latest Latest
Warning

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

Go to latest
Published: May 8, 2018 License: MIT Imports: 14 Imported by: 0

README

netgo is an fast and small epoll event loop networking framework. It direct use syscalls rather than using the standard Go net package, and easy to use.

Features

  • Linux only
  • Tcp only
  • Simple API
  • Low memory usage
  • Socket option

Getting Started

Installing

To start using netgo, install Go and run go get:

$ go get -u github.com/pigogo/netgo

This will retrieve the library.

Documentation

Index

Constants

View Source
const (
	SeqidMASK  = 0x7FF
	OffsetMASK = 0xFFFFF
)
View Source
const (
	//INVALIDADDR invalid socket addr offset
	INVALIDADDR = math.MaxInt32
)

Variables

View Source
var (
	ErrOutcacheFull       = errors.New("out cache full")
	ErrInputcacheFull     = errors.New("input cache full")
	ErrUnknowSysError     = errors.New("unknow system error")
	ErrListenError        = errors.New("listen socket error")
	ErrNoSocketAvailable  = errors.New("no socket available")
	ErrInvalidListenAddr  = errors.New("invalid listen addr")
	ErrInvalidConnectAddr = errors.New("invalid connect addr")
	ErrInvalidSocketAddr  = errors.New("invalid socket address")
	ErrInvalidPacketRecv  = errors.New("invalid packet recv")
	ErrSocketBeClosed     = errors.New("socket be closed")
)

Functions

func SetKeepAlive

func SetKeepAlive(fd, secs int) error

func SetLinger

func SetLinger(fd, sec int) error

func SetNodelay

func SetNodelay(fd int) error

func SetReusedAddr

func SetReusedAddr(fd int) error

func SetReusedPort

func SetReusedPort(fd int) error

func SetsockoptInet4Addr

func SetsockoptInet4Addr(fd, level, name int, arg [4]byte) error

SetsockoptInet4Addr wraps the setsockopt network call with an IPv4 address.

func SetsockoptInt

func SetsockoptInt(fd, level, name, arg int) error

SetsockoptInt wraps the setsockopt network call with an int argument.

func SetsockoptLinger

func SetsockoptLinger(fd, level, name int, l *syscall.Linger) error

SetsockoptLinger wraps the setsockopt network call with a Linger argument.

Types

type FD

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

func (*FD) Init

func (fd *FD) Init(f int, laddr, raddr syscall.Sockaddr)

func (*FD) Reset

func (fd *FD) Reset()

type INetgo

type INetgo interface {
	Init(func(body []byte, naddr int32), SocketOption) error
	Send(naddr int32, buf []byte) error
	Connect(addr string) (naddr int32, err error)
	Close(addr int32) error
	Listen(laddr string) (err error)
	Serve() error
}

func NewNetgo

func NewNetgo() INetgo

type SocketOption

type SocketOption struct {
	Linger           int
	Nodelay          bool
	Keepalive        bool
	KeepIdle         int
	ReusedAddr       bool
	MaxListenBacklog int
}

Directories

Path Synopsis
sample

Jump to

Keyboard shortcuts

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