jmcph4 / rainyday

A minimalist BitTorrent client respecting the Unix philosophy
MIT License
0 stars 0 forks source link

Define all protocol messages #5

Open jmcph4 opened 3 years ago

jmcph4 commented 3 years ago

Description

BEP 3 specifies several messages that comprise the BitTorrent peer protocol:

  1. Choke
  2. Unchoke
  3. Interested
  4. Not Interested
  5. Have
  6. Bitfield
  7. Request
  8. Piece
  9. Cancel

There are a few implementation strategies that come to mind:

  1. Define a struct for each message
    • Naive approach
    • Wasteful
    • Not very DRY
  2. Define a single struct for a generic message and then define functions that read and write each message

Neither seem very clean at the moment. Some things to consider:

Acceptance Criteria

jmcph4 commented 3 years ago

@alecdwm Keen to hear your input from a design perspective.

jmcph4 commented 3 years ago

An additional resource which (while unofficial) is very helpful: BitTorrentSpecification.