func (c *Conn) Write(b []byte) (int, error) {
	defer c.g.onWriteBufferFree(c, b)
	c.mux.Lock()
	if c.closed {
		c.mux.Unlock()
		return -1, errClosed
	}
	c.g.beforeWrite(c)
	n, err := c.write(b)
	if err != nil && !errors.Is(err, syscall.EINTR) && !errors.Is(err, syscall.EAGAIN) {
		c.closed = true
		c.mux.Unlock()
		c.closeWithErrorWithoutLock(err)
		return n, err
	}
	if len(c.writeBuffer) == 0 {
		if c.wTimer != nil {
			c.wTimer.Stop()
			c.wTimer = nil
		}
	} else {
		c.modWrite()
	}
	c.mux.Unlock()
	return n, err
}
Write implements Write.
package nbio
import (
	"errors"
	"net"
	"sync"
	"syscall"
	"time"
	"github.com/lesismal/nbio/mempool"
)
type Conn struct {
	mux sync.Mutex
	g *Gopher
	fd int
	rTimer *htimer
	wTimer *htimer
	writeBuffer []byte
	closed   bool
	isWAdded bool
	closeErr error
	lAddr net.Addr
	rAddr net.Addr
	ReadBuffer []byte
	session interface{}
	chWaitWrite chan struct{}
	execList []func()
	DataHandler func(c *Conn, data []byte)
}
func (c *Conn) Hash() int {
	return c.fd
}
func (c *Conn) Read(b []byte) (int, error) {
	c.mux.Lock()
	if c.closed {
		c.mux.Unlock()
		return 0, errClosed
	}
	c.mux.Unlock()
	n, err := syscall.Read(c.fd, b)
	if err == nil {
		c.g.afterRead(c)
	}
	return n, err
}