I'm working on a P2P file sharing program and in order to pass the files in small bits I need to split the uploaded file somehow. Now, I've made a program that splits a file into small files and puts them in a folder using C# Stream class, and it can also rebuild it. However, it's inefficient and takes a lot of time. I thought of reading the data from the stream with an offset according to the requested file and then sending it without saving. However, I don't know how to add it to the receiving end at the right order as the data will not be sent in order.
On a side note, how does bitTorrent do that kind of functionality?
thanks