anysocket icon indicating copy to clipboard operation
anysocket copied to clipboard

How would one create Anysocket using ptp2

Open disarticulate opened this issue 1 month ago • 3 comments

https://github.com/subins2000/p2pt allows to connect peers in browsers using existing webtorrent tracker network, which if performant, means one could setup a webrtc "server" and "client".

How would the abstract client/server be setup?

disarticulate avatar Oct 18 '25 22:10 disarticulate

I haven't used p2pt, but after a quick look over the docs, i think it can work if you clone the ws transport module and implement the p2pt library over it. The only small issue i can see is with the tracker connection, but i think it's possible to implement it in the transport module.

I need to look over the library a bit more, but at first glance, it should be doable

lynxaegon avatar Oct 19 '25 08:10 lynxaegon

cool, any pointers would be great.

disarticulate avatar Oct 19 '25 17:10 disarticulate

PR's are welcome 😄

The concept of anysocket is simple, and hopefully enough. Everything is based on a transport layer/module, which you can find the code for here

The Peer is a client and the Transport is the network protocol.

The Peer can send a message and emit connect/disconnect messages. The Transport is how you define the connection, or how you discover peers.

Now, if you want to implement the p2pt library, what you need to do is to implement the Server creation / Discovery of peers in the transport layer and add/remove peers from there. The new Peer(socket) (look into the ws transport module), the socket is anything you want, and it should be something that can be used to send a message over that protocol.

lynxaegon avatar Oct 19 '25 20:10 lynxaegon