How I built EasyShare: peer-to-peer file sharing in Java
BitTorrent-style file sharing in plain Java with no external libraries. Files are split into pieces, every piece is SHA-1 checked, and peers download from each other in parallel while still downloading themselves. Try it live · Source code The problem Move files between computers with no central file server, and prove that every byte that arrives is the byte that was sent. Decisions that shaped…
Niranjan developed EasyShare, a peer-to-peer file sharing application in Java, without relying on any external libraries. The program splits files into pieces, verifies each piece using SHA-1 hashing, and enables parallel downloads from multiple peers while still downloading the file themselves. You can try the application live, and access its source code.
The primary objective was to transfer files between computers without the need for a central file server, and to ensure that every byte received is the exact byte that was sent. All received pieces are hashed using SHA-1, and any corrupt pieces are rejected and redownloaded. The demo includes a peer that intentionally corrupts 15% of the pieces it sends, demonstrating the effectiveness of the check.
The application uses rarest-first selection for the swarm, allowing peers to share pieces while they are still downloading and preventing a single machine from becoming a bottleneck. To discover other peers, EasyShare utilizes three methods: a TCP tracker, LAN multicast over UDP, and manual connection through ip:port. The application has no external dependencies beyond the Java Development Kit (JDK).
EasyShare can pause and resume file transfers, ensuring that progress is not lost when the program is restarted. Additionally, it features a web dashboard and a phone page for devices connected to the same Wi-Fi network. The program was built using Java 17, TCP and UDP sockets, multithreading, SHA-1 hashing, and HTML.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.