(09-10-2017, 02:36 PM)z3bra Wrote: We reached a milestone here! libgbt can up/download torrents, with multiple peers. It can accept new connections as well (when seeding only for now).
Basic functionality being there, let's fuck it up and rewrite some bits! Here is what I'm not happy with, or what I want to add/improve:

z3bra,

Do you have a test suite set up? It would make things (like fucking up the API to make it easier to use) a little bit safer.

I can help with writing those tests if you like; when it comes to small C projects I would usually go for just some executable that links to the library and calls assert() a bunch.

It had tests at first, for internal functions (bencoding related mostly). Now that only the API is accessible I don't see the point for tests. What would the test do? Download a file, and checksum it? you'd depend on access to the network here. Another idea would be to use a local tracker, spawned for the tests. Not really helpful either...

I wanted to have tests at first, but the simplest way to test is to do it manually at this point.

I'm bringing back to life this old thread. Due to the lack of interest in the original project (and seeing the mess I created...), I decided to rewrite this project from scratch, by using another approach: http://git.z3bra.org/libeech/log.html

It now uses poll() instead of select(), and make use of callbacks functions to receive messages.
The bencoding part has also been fully reimplement to be heapless (so not a single malloc() call!)

As I write this, the lib can connect to a peer, request pieces and write them to a cache file.
To put it simply, I can download a file via BitTorrent!

I'm now reaching some important steps in the implementation, regarding management of cache files, choosing to store things in memory or on the disk, and more importantly, how to communicate with multiple peers at once!

I'm looking for help in networking programming in C, or any idea regarding torrent download/upload algorithms.