Dr. Edward Felten recently posted a piece of code called TinyP2P, which demonstrates how easy it is to create a peer-to-peer filesharing application by doing it in just 15 lines of Python. However, TinyP2P uses a ready-made XMLRPC server library, which seems to me to be taking the easy way out. Here's my response: MoleSter, a non-trivial filesharing application in 6 lines of Perl, using no protocol library more sophisticated than TCP.
NEW: Thanks to a bunch of suggestions from Rob Kinyon, as well as more testing and protocol work of my own, MoleSter is now (version 0.0.4) down to 6 lines and 466 bytes, and works better than ever before. Peer discovery now happens semi-automatically, so you need to do fewer explicit h/ commands to get linked into the network.