You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
conf:= nbio.Configstruct {
// Name describes your gopher name for logging, it's set to "NB" by defaultName: "NB",
// MaxLoad represents the max online num, it's set to 10k by defaultMaxLoad: 1024*10,
// NPoller represents poller goroutine num, it's set to runtime.NumCPU() by defaultNPoller: runtime.NumCPU(),
// ReadBufferSize represents buffer size for reading, it's set to 16k by defaultReadBufferSize: 1024*16,
// MaxWriteBufferSize represents max write buffer size for Conn, it's set to 1m by default.// if the connection's Send-Q is full and the data cached by nbio is // more than MaxWriteBufferSize, the connection would be closed by nbio.MaxWriteBufferSizeuint32// LockListener represents listener's goroutine to lock thread or not, it's set to false by default.LockListenerbool// LockPoller represents poller's goroutine to lock thread or not.LockPollerbool
}
// BeforeRead registers callback before syscall.Read// the handler would be called only on windowsg.OnData(func(c*Conn, data []byte) {
c.SetReadDeadline(time.Now().Add(time.Second*30))
})
Handle Conn After Read
// AfterRead registers callback after syscall.Read// the handler would be called only on *nixg.BeforeRead(func(c*Conn) {
c.SetReadDeadline(time.Now().Add(time.Second*30))
})
Handle Conn Before Write
g.OnData(func(c*Conn, data []byte) {
c.SetWriteDeadline(time.Now().Add(time.Second*5))
})