Documentation ¶
Overview ¶
Package message has been literally copied code from veggiefender/torrent-client
Index ¶
Constants ¶
View Source
const ( // Choke chokes the receiver Choke messageID = 0 // Unchoke unchokes the receiver Unchoke messageID = 1 // Interested expresses interest in receiving data Interested messageID = 2 // NotInterested expresses disinterest in receiving data NotInterested messageID = 3 // Have alerts the receiver that the sender has downloaded a piece Have messageID = 4 // Bitfield encodes which pieces that the sender has downloaded Bitfield messageID = 5 // Request requests a block of data from the receiver Request messageID = 6 // Piece delivers a block of data to fulfill a request Piece messageID = 7 // Cancel cancels a request Cancel messageID = 8 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Message ¶
type Message struct { ID messageID Payload []byte }
Message stores ID and payload of a message
func FormatRequest ¶
FormatRequest creates a REQUEST message
func Read ¶
Read reads a message from stream. The first 4 bytes of the stream gives the length of the message and hence we get the length then read that many bytes from string. Return nil on keep alive msg,i.e to not close the connection
Click to show internal directories.
Click to hide internal directories.