netpoll

package
v1.0.0-beta.6 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrEvents ...
	ErrEvents = unix.EPOLLERR | unix.EPOLLHUP
	// OutEvents ...
	OutEvents = ErrEvents | unix.EPOLLOUT
	// InEvents ...
	InEvents = ErrEvents | unix.EPOLLIN | unix.EPOLLPRI | unix.EPOLLRDHUP
)

Variables

This section is empty.

Functions

func IP6ZoneToString

func IP6ZoneToString(zone int) string

IP6ZoneToString converts an IP6 Zone unix int to a net string returns "" if zone is 0

func ReusePortListen

func ReusePortListen(proto, addr string) (net.Listener, error)

ReusePortListen returns a net.Listener for TCP.

func ReusePortListenPacket

func ReusePortListenPacket(proto, addr string) (net.PacketConn, error)

ReusePortListenPacket returns a net.PacketConn for UDP.

func SetKeepAlive

func SetKeepAlive(fd, secs int) error

SetKeepAlive sets the keepalive for the connection.

func SockaddrToIPAndZone

func SockaddrToIPAndZone(sa unix.Sockaddr) (net.IP, string)

SockaddrToIPAndZone converts a Sockaddr to a net.IP (with optional IPv6 Zone) Returns nil if conversion fails.

func SockaddrToTCPOrUnixAddr

func SockaddrToTCPOrUnixAddr(sa unix.Sockaddr) net.Addr

SockaddrToTCPOrUnixAddr converts a Sockaddr to a net.TCPAddr or net.UnixAddr. Returns nil if conversion fails.

func SockaddrToUDPAddr

func SockaddrToUDPAddr(sa unix.Sockaddr) *net.UDPAddr

SockaddrToUDPAddr converts a Sockaddr to a net.UDPAddr Returns nil if conversion fails.

func SockaddrToUnixAddr

func SockaddrToUnixAddr(sa unix.Sockaddr) *net.UnixAddr

SockaddrToUnixAddr converts a Sockaddr to a net.UnixAddr Returns nil if conversion fails.

Types

type Poller

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

Poller represents a poller which is in charge of monitoring file-descriptors.

func OpenPoller

func OpenPoller() (*Poller, error)

OpenPoller instantiates a poller.

func (*Poller) AddRead

func (p *Poller) AddRead(fd int) error

AddRead registers the given file-descriptor with readable event to the poller.

func (*Poller) AddReadWrite

func (p *Poller) AddReadWrite(fd int) error

AddReadWrite registers the given file-descriptor with readable and writable events to the poller.

func (*Poller) AddWrite

func (p *Poller) AddWrite(fd int) error

AddWrite registers the given file-descriptor with writable event to the poller.

func (*Poller) Close

func (p *Poller) Close() error

Close closes the poller.

func (*Poller) Delete

func (p *Poller) Delete(fd int) error

Delete removes the given file-descriptor from the poller.

func (*Poller) ModRead

func (p *Poller) ModRead(fd int) error

ModRead renews the given file-descriptor with readable event in the poller.

func (*Poller) ModReadWrite

func (p *Poller) ModReadWrite(fd int) error

ModReadWrite renews the given file-descriptor with readable and writable events in the poller.

func (*Poller) Polling

func (p *Poller) Polling(callback func(fd int, ev uint32, job internal.Job) error) (err error)

Polling blocks the current goroutine, waiting for network-events.

func (*Poller) Trigger

func (p *Poller) Trigger(job internal.Job) error

Trigger wakes up the poller blocked in waiting for network-events and runs jobs in asyncJobQueue.

Jump to

Keyboard shortcuts

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