sys

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

sys just generalized some needed syscalls from different platforms.

Index

Constants

View Source
const (
	MaxPollSize         = 1024
	MinPollSize         = 32
	InitPollSize        = 128
	EVFilterFd          = -0xd
	DefaultTCPKeepAlive = 15 // Seconds
)
View Source
const (
	TCP_KEEPINTVL = syscall.TCP_KEEPINTVL
	TCP_KEEPIDLE  = syscall.TCP_KEEPIDLE
	SOL_SOCKET    = syscall.SOL_SOCKET
	IPPROTO_TCP   = syscall.IPPROTO_TCP
	SO_KEEPALIVE  = syscall.SO_KEEPALIVE
	SO_REUSEPORT  = 0xf
)
View Source
const (
	ErrEvents      = syscall.EPOLLERR | syscall.EPOLLHUP | syscall.EPOLLRDHUP
	OutEvents      = ErrEvents | syscall.EPOLLOUT
	InEvents       = ErrEvents | syscall.EPOLLIN | syscall.EPOLLPRI
	ClosedFdEvents = 0
)
View Source
const (
	EAGAIN     = syscall.EAGAIN
	ECONNRESET = syscall.ECONNRESET
	EINVAL     = syscall.EINVAL
	ENOENT     = syscall.ENOENT
)
View Source
const (
	ReadEvents      = syscall.EPOLLPRI | syscall.EPOLLIN
	WriteEvents     = syscall.EPOLLOUT
	ReadWriteEvents = ReadEvents | WriteEvents
)

Variables

This section is empty.

Functions

func Accept

func Accept(listenerFd int, timeout ...time.Duration) (int, syscall.Sockaddr, error)

func AddRead

func AddRead(pollFd, fd int) (err error)

func AddReadWrite

func AddReadWrite(pollFd, fd int) (err error)

func AddWrite

func AddWrite(pollFd, fd int) (err error)

func AsyncHandleEvents added in v1.0.1

func AsyncHandleEvents(events uint32, handler EventHandler)

func AsyncHandleEventsAndWait added in v1.1.0

func AsyncHandleEventsAndWait(events uint32, handler EventHandler, wg *sync.WaitGroup)

func CloseFd

func CloseFd(fd int) error

func CreatePoll

func CreatePoll() (pollFd, pollEvFd int, err error)

func HandleEvents

func HandleEvents(events uint32, handler EventHandler) (err error)

func ModRead

func ModRead(pollFd, fd int) (err error)

func ModReadWrite

func ModReadWrite(pollFd, fd int) (err error)

func ModWrite

func ModWrite(pollFd, fd int) (err error)

func Read

func Read(fd int, p []byte) (n int, err error)

func Readv

func Readv(fd int, iovs [][]byte) (n int, err error)

func SetKeepAlive

func SetKeepAlive(fd int, timeout ...time.Duration) (err error)

func SetRecvBufferSize

func SetRecvBufferSize(fd, size int) error

func SetReuseAddr

func SetReuseAddr(fd int) error

func SetReusePort

func SetReusePort(fd int) error

func SetSendBufferSize

func SetSendBufferSize(fd, size int) error

func SocketClosed

func SocketClosed(fd int) bool

func Trigger

func Trigger(pollEvFd int) (err error)

func UnRegister

func UnRegister(pollFd, fd int) (err error)

func WaitPoll

func WaitPoll(pollFd, pollEvFd int, w WaitCallback, doCallbackErr DoError, wg *sync.WaitGroup) error

func Write

func Write(fd int, p []byte) (n int, err error)

func WriteUdp

func WriteUdp(fd int, p []byte, flags int, to syscall.Sockaddr) (err error)

func Writev

func Writev(fd int, iovs [][]byte) (n int, err error)

Types

type DoError

type DoError func(err error) error

type EventHandler

type EventHandler interface {
	WriteToFd() error
	AsyncWriteToFd()
	AsyncWriteToFdAndWait(wg *sync.WaitGroup)
	ReadFromFd() error
	AsyncReadFromFd()
	AsyncReadFromFdAndWait(wg *sync.WaitGroup)
	Close() error
	AsyncClose()
}

type WaitCallback

type WaitCallback func(fd int, events uint32, trigger bool, wg *sync.WaitGroup) (newTrigger bool, err error)

Jump to

Keyboard shortcuts

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