Do you mean a script that connects to an existing P2P network.. if so, then you would have to browse the net (
Google !) for the protocol used to connect to these and i'm guessing you wont find anything of use..
However if you are talking about creating your own this has been done in the past with using Sockets (/help sockets) to connect to a network/server, and use a "channel" as a medium to list/search/connect with the requested files.
Please clarify which you are talking about..
Eamonn.