Oddly the uploading part is missing. To be a peer, an equal, things have to flow both ways. Bittorrent wouldn't work otherwise.
After the handshake you'll need state machines to handle multiple peers, piece-sets to track what you've downloaded, the rarest-first algorithm[0], message processing and so on. The final result of having a downloaded file falls out of that almost as a side-product at some point.