Updating tracker in bit torrent
The peer protocol refers to pieces of the file by index as described in the metainfo file, starting at zero.When a peer finishes downloading a piece and checks that the hash matches, it announces that it has that piece to all of its peers.The leading character is a length prefix, put there in the hope that other new protocols may do the same and thus be trivially distinguishable from each other.All later integers sent in the protocol are encoded as four bytes big-endian.
If you want to make any extensions to metainfo files or tracker queries, please coordinate with Bram Cohen to make sure that all extensions are done compatibly.maps to the number of bytes in each piece the file is split into.For the purposes of transfer, files are split into fixed-size pieces which are all the same length except for possibly the last one which may be truncated. For the purposes of the other keys, the multi-file case is treated as only having a single file by concatenating the files in the order they appear in the files list.Interest state must be kept up to date at all times - whenever a downloader doesn't have something they currently would ask a peer for in unchoked, they must express lack of interest, despite being choked.Implementing this properly is tricky, but makes it possible for downloaders to know which peers will start downloading immediately if unchoked. When data is being transferred, downloaders should keep several piece requests queued up at once in order to get good TCP performance (this is called 'pipelining'.) On the other side, requests which can't be written out to the TCP buffer immediately should be queued up in memory rather than kept in an application-level network buffer, so they can all be thrown out when a choke happens.