P2P TCP network not working as expected

I’m trying to implement a P2P TCP network in Elixir (with ranch and gen_tcp) but I’m experiencing some issues and can’t understand the reason.


I’ve created the repo above that implements the network and reproduces the issue I’m going through. Please check the README.md file where I detail the issue.

I’d like someone to explain to me what I’m doing wrong and also if the code can be improved somehow (I’m still learning GenServers, Supervisors and OTP in general).

Thanks in advance for your support and happy holidays everyone!

I now know what the issue was about. Basically, on the client-side, I wasn’t setting :gen_tcp.controlling_process/2 to make the socket controlled by the Network.Peer worker. The issue is fixed on the e76fc1b0ef195d3b64071ab06fe8ab405b05495d commit.

I’ll keep the repo up as reference for anyone that want’s to implement a P2P network.

This was pointed out by Andrew Vy (@vy on Elixir’s Slack) and Rockwell Schrock (@schrockwell) for whom I’m really grateful for the help!