Why bittorrent needs as many ports?..Why not just one-2? I know that some of them are used for peer discovery, but dont exactly know how is this happening. Can you please provide more technical information about how bittorent works(deeper than its described in wikipedia)?
2 Answers
Google says:
"A BitTorrent client normally associates the TCP port number 6881. However, if this port is busy for some reason, the client will instead try successively higher ports (6882, 6883, and so on up to a limit of 6999). In order for outside BitTorrent clients to reach this one, they must be able to connect to the correct port."
Here is the specification incase you were curious, http://wiki.theory.org/BitTorrentSpecification

- 1,643
- 1
- 9
- 8
-
-
I don't think he's asking about the port the server is listening on. I think he's asking about the ports used by the connections. – David Schwartz Nov 08 '11 at 07:18
-
@David Schwartz and you are right...Sorry for my bad question construction. – 0x49D1 Nov 08 '11 at 07:23
BitTorrent needs many ports because it makes many outbound connections. Typical operating systems (including Windows, Linux, and most others) only permit a single outbound connection per local port per IP address. All of your inbound connections will use the same local port. But each outbound connection will be assigned a random local port by the operating system.
Your outbound connections will have the remote port that the other client is listening on. Your inbound connections will have essentially random remote ports, since they are allocated by the remote operating system effectively randomly.
Typically, a TCP connection only has a well-known port on the receiving side. BitTorrent is not an exception to the usual rule. Most likely it only seems unusual to you because you're not used to having a large number of inbound connections. Also, some people specifically change their BitTorrent server port, and you have to connect to them on whatever port they happen to be using, whether it's the well-known normal port (6881) or not.

- 31,449
- 2
- 55
- 84