>>1254520>>1254527There is no central server.
A file is spilt into many parts, called "chunks", the file is hashed, this hash is used to identify it, this allows for users to give it arbitrary file names.
The system when strating up discovers the network in a way similar to how normal routers do, they first contact your logical neighbours, which then give you their neighbour tables, which also contain the neighbours of THOSE neighbours, which also contain....
Through the splitting into chunks every member can easily become seeding part of the network.
The rest can be donewith various protocols, you CAN just do it unprotected via the stadard IP protocol, typically via UDP because for TCP all that handshaking ans establishing connections just for tiny chunks would be too much overhead.
When you click a file to download it discovers via the hash which IP addresses have the file or chunks of it (is a seeder), connects them and requests a part, the download for each is then just a standard IP based UDP download over the normal network, just using the client's port.
As soon as you have a chunk your client announces that to the network, other clients can now also contact YOU for uploading it to them - you have become a seeder.
>>1254527In the end yes - you have to trust the program that it really does only share the files you explicitely declared it to.
When adding a file to your shared list it scans it, creates the hash and waits for a request for a file of this hash or a search.
In theory it could break out of this artificial restriction and simply share everything after you trusted it the first time and allowed transfer, it is on you to keep an eye on it.
Most of those programs are open source though, so such a behaviour would quickly be discovered.