I am currently writing a BitTorrent client and from my understanding I can use a single local port to connect to different peers and communicate with them independently.
If I were to write a server, i.e. I would have to accept connections then I know I could use a Java ServerSocket to listen on the same port and handle connections independently otherwise. However, what I want to do however is to initiate connections rather than waiting for them to be initiated (as there is no server), and I want to use the same local port for these (so I can connect to say hundreds of peers sharing the same port). How can I correctly do this?