message

package
v0.0.0-...-9239fd2 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MsgChoke msgID = 0

	MsgUnchoke msgID = 1

	MsgInterested msgID = 2

	MsgNotInterested msgID = 3

	MsgHave msgID = 4

	MsgBitfield msgID = 5

	MsgRequest msgID = 6

	MsgPiece msgID = 7
)
View Source
const PieceMessageByteLength = 17

Variables

View Source
var EmptyPayload []byte

Functions

func SendPiece

func SendPiece(index, begin, blockSize uint32, writer io.Writer) error

func SendRequest

func SendRequest(index, begin, length uint32, writer io.Writer) error

func TryParseHave

func TryParseHave(msg *BittorrentMessage) (index uint32, err error)

func TryParsePiece

func TryParsePiece(msg *BittorrentMessage) (index, begin uint32, err error)

func TryParseRequest

func TryParseRequest(msg *BittorrentMessage) (index, begin, length uint32, err error)

func WriteHave

func WriteHave(index uint32, writer io.Writer) error

Types

type BittorrentMessage

type BittorrentMessage struct {
	ID      msgID
	Payload []byte
}

func Read

func Read(r io.Reader) (*BittorrentMessage, error)

func (*BittorrentMessage) Validate

func (m *BittorrentMessage) Validate() error

func (*BittorrentMessage) Write

func (m *BittorrentMessage) Write(writer io.Writer) error

Jump to

Keyboard shortcuts

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