Loading...

Build your own BitTorrent

Learn about .torrent files, the BitTorrent Peer Protocol and more

Start Building
bittorrent
C
bittorrent
C++
bittorrent
C#
bittorrent
Go
bittorrent
Python
bittorrent
Rust
bittorrent
Elixir
bittorrent
Haskell
bittorrent
Java
bittorrent
JavaScript
bittorrent
Kotlin
bittorrent
Ruby
bittorrent
TypeScript
bittorrent
Zig

BitTorrent is a peer-to-peer file sharing protocol used for distributing large amounts of data. In this challenge, you'll build a BitTorrent client that's capable of downloading a publicly available file using the BitTorrent protocol.

Along the way, you'll learn about the BitTorrent protocol, .torrent files more.

Stages

Decode bencoded strings
Decode bencoded integers
Decode bencoded lists
Decode bencoded dictionaries
Parse torrent file
Calculate info hash
Piece hashes
Discover peers
Peer handshake
Download a piece
Download the whole file

Magnet Links

Parse magnet link
Announce extension support
Send extension handshake
Receive extension handshake
Request metadata
Receive metadata
Download a piece
Download the whole file