Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyOpts(fd int, opts ...sonicopts.Option) error
- func Connect(network, addr string, opts ...sonicopts.Option) (fd int, localAddr, remoteAddr net.Addr, err error)
- func ConnectTCP(network, addr string, timeout time.Duration, opts ...sonicopts.Option) (fd int, localAddr, remoteAddr net.Addr, err error)
- func ConnectTimeout(network, addr string, timeout time.Duration, opts ...sonicopts.Option) (fd int, localAddr, remoteAddr net.Addr, err error)
- func ConnectUDP(network, addr string, timeout time.Duration, opts ...sonicopts.Option) (fd int, localAddr, remoteAddr net.Addr, err error)
- func CreateSocketTCP(network, addr string, nonblocking bool) (fd int, tcpAddr *net.TCPAddr, err error)
- func CreateSocketUDP(network, addr string) (fd int, udpAddr *net.UDPAddr, err error)
- func FromSockaddr(sockAddr syscall.Sockaddr) net.Addr
- func FromSockaddrUDP(sockAddr syscall.Sockaddr, to *net.UDPAddr) *net.UDPAddr
- func IsNoDelay(fd int) (bool, error)
- func IsNonblocking(fd int) (bool, error)
- func Listen(network, addr string, opts ...sonicopts.Option) (int, net.Addr, error)
- func ListenUDP(network, addr string, opts ...sonicopts.Option) (int, net.Addr, error)
- func Sockaddr(fd int) (syscall.Sockaddr, error)
- func SocketAddress(fd int) (net.Addr, error)
- func ToSockaddr(addr net.Addr) syscall.Sockaddr
- type Event
- type EventFd
- type EventType
- type Handler
- type ITimer
- type Pipe
- type Poller
- type PollerEvent
- type Slot
- type Timer
Constants ¶
View Source
const ( PollerReadEvent = PollerEvent(syscall.EPOLLIN) PollerWriteEvent = PollerEvent(syscall.EPOLLOUT) )
Variables ¶
View Source
var (
ListenBacklog int = 2048
)
Functions ¶
func Connect ¶
func Connect( network, addr string, opts ...sonicopts.Option, ) (fd int, localAddr, remoteAddr net.Addr, err error)
Connect connects to the specified endpoint. The created connection can be optionally bound to a local address by passing the option sonicopts.BindBeforeConnect(to net.Addr)
If network is of type UDP, then addr is the address to which datagrams are sent by default, and the only address from which datagrams are received.
func ConnectTCP ¶
func ConnectTimeout ¶
func ConnectUDP ¶
func CreateSocketTCP ¶
func CreateSocketUDP ¶
func FromSockaddrUDP ¶
func IsNonblocking ¶
Types ¶
type Pipe ¶
type Pipe struct {
// contains filtered or unexported fields
}
func (*Pipe) SetReadNonblock ¶
func (*Pipe) SetWriteNonblock ¶
type Poller ¶
type Poller interface { // Poll polls the status of the underlying events registered with SetRead or SetWrite, returning if any events // occurred. // // A call to Poll will block until either: // - an event occurs // - the call is interrupted by a signal handler; or // - the timeout expires Poll(timeoutMs int) (n int, err error) // Pending returns the number of registered events which have not yet occurred. Pending() int64 // Post instructs the Poller to execute the provided handler in the Poller's goroutine in the next Poll call. // // Post is safe for concurrent use. Post(func()) error // Posted returns the number of handlers registered with Post. // // Posted is safe for concurrent use. Posted() int // SetRead registers interest in read events on the provided slot. SetRead(slot *Slot) error // SetWrite registers interest in write events on the provided slot. SetWrite(slot *Slot) error // DelRead deregisters interest in read events on the provided slot. DelRead(slot *Slot) error // DelWrite deregisters interest in write events on the provided slot. DelWrite(slot *Slot) error // Del deregisters interest in all events on the provided slot. Del(slot *Slot) error // Close closes the Poller. No calls to Poll should be made after Close. // // Close is safe for concurrent use. Close() error // Closed returns true if the Poller has been closed. // // Closed is safe for concurrent use. Closed() bool }
type PollerEvent ¶
type PollerEvent uint32
type Slot ¶
type Slot struct { Fd int // A file descriptor which uniquely identifies a Slot. Callers must set it up at construction time. // Events registered with this Slot. Essentially a bitmask. It can contain a read event, a write event, or both. // Every event from here has a corresponding Handler in Handlers. // // Defined by Poller, which is platform-specific. Since this is a bitmask, the Poller guarantees that each // platform-specific event is a power of two. Events PollerEvent // Callbacks registered with this Slot. The poller dispatches the appropriate read or write callback when it // receives an event that's in Events. Handlers [MaxEvent]Handler }
Click to show internal directories.
Click to hide internal directories.