message

package
v0.0.0-...-a441d8e Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseHave

func ParseHave(msg *Message) (int, error)

func ParsePiece

func ParsePiece(index int, buf []byte, msg *Message) (int, error)

func ParseRequest

func ParseRequest(msg *Message) (index int, begin int, length int, err error)

Types

type Message

type Message struct {
	ID      MessageID
	Payload []byte
}

func FormatHave

func FormatHave(index int) *Message

func FormatPiece

func FormatPiece(index int, begin int, b []byte) *Message

func FormatRequest

func FormatRequest(index int, begin int, length int) *Message

func Read

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

func (*Message) Serialize

func (m *Message) Serialize() []byte

func (*Message) String

func (m *Message) String() string

type MessageID

type MessageID uint8
const (
	MsgChoke         MessageID = 0
	MsgUnchoke       MessageID = 1
	MsgInterested    MessageID = 2
	MsgNotInterested MessageID = 3
	MsgHave          MessageID = 4
	MsgBitfield      MessageID = 5
	MsgRequest       MessageID = 6
	MsgPiece         MessageID = 7
	MsgCancel        MessageID = 8
)

Jump to

Keyboard shortcuts

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