I am implementing a bittorrent client in Elixir as a learning exercise.
Reading multiple docs, it appears that a proper client should not only be able to create outbound socket connections but also listen on a port and accept inbound connections.
But I cannot find docs about Alice and Bob trying to connect to each other simultaneously.
That would end up with two connections with the same peer (for the same info hash / torrent). Now if I want to track my connections the reasonable thing seems to associate them with the torrent id + peer id, which means boths connections would have the same identifier.
Is there something I missed that prevents that case? Or do clients generally just close one of the two connections randomly? Or maybe the IP (and even port) can be part of the ID so keep both connections is actually OK (though useless I guess).
What would be the proper solution?
Thank you.