代码拉取完成,页面将自动刷新
package netutil
import (
"bufio"
"github.com/xiaonanln/goworld/engine/consts"
)
// BufferedConnection provides buffered write to connections
type BufferedConnection struct {
Connection
bufReader *bufio.Reader
bufWriter *bufio.Writer
}
// NewBufferedWriteConnection creates a new connection with buffered write based on underlying connection
func NewBufferedConnection(conn Connection) *BufferedConnection {
brc := &BufferedConnection{
Connection: conn,
}
brc.bufReader = bufio.NewReaderSize(conn, consts.BUFFERED_READ_BUFFSIZE)
brc.bufWriter = bufio.NewWriterSize(conn, consts.BUFFERED_WRITE_BUFFSIZE)
return brc
}
// Read
func (brc *BufferedConnection) Read(p []byte) (int, error) {
return brc.bufReader.Read(p)
}
func (brc *BufferedConnection) Write(p []byte) (int, error) {
return brc.bufWriter.Write(p)
}
func (brc *BufferedConnection) Flush() error {
err := brc.bufWriter.Flush()
if err != nil {
return err
}
return brc.Connection.Flush()
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。