cbuffered

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 5, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package cbuffered 实现读缓冲的net.conn接口

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	net.Conn
	// contains filtered or unexported fields
}

Conn conn with bufio.Reader

func New

func New(c net.Conn, sizes ...int) *Conn

New with net.Conn and a new Reader whose buffer has at least the specified size

func (*Conn) Buffered

func (sf *Conn) Buffered() int

Buffered returns the number of bytes that can be read from the current buffer.

func (*Conn) Peek

func (sf *Conn) Peek(n int) ([]byte, error)

Peek returns the next n bytes without advancing the reader. The bytes stop being valid at the next read call. If Peek returns fewer than n bytes, it also returns an error explaining why the read is short. The error is ErrBufferFull if n is larger than b's buffer size.

func (*Conn) Read

func (sf *Conn) Read(p []byte) (int, error)

Read reads data into p.

func (*Conn) ReadByte

func (sf *Conn) ReadByte() (byte, error)

ReadByte reads and returns a single byte.

func (*Conn) UnreadByte

func (sf *Conn) UnreadByte() error

UnreadByte unreads the last byte. Only the most recently read byte can be unread.

Jump to

Keyboard shortcuts

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