c - Can I reuse (ephemeral) ports connecting to different hosts? -


Whether an operating system can reuse source port number for a connection to a different destination address / port combination is?

If I have connect for the host and keep those connections open, in the end I'm going out of unique source ports, ending the temporary limit , Non-root category (1025- 65,535; assuming non-root) or full range (0-65,535) I want to know whether they represent the actual range for the number of hosts. I can have a simultaneous connection I agree that what criteria Promises (or not), as well as the reality on Linux (windows bonus will be).

I know that the number of other limitations likely to open many connections; This is a different issue and the question is. If it matters, then this large scale connection process will be split into a large number of such kind. I'm interested in this matter where I am requesting a short-term port, manually dam () if not reused under ports of "normal" conditions, then user- There are ways to change that behavior from the place (at which point the dam () becomes an option for a specific point)?

By default, the kernel does not reuse any in-use port for a short-term port , Which could result in failure if you have 64K + simultaneous port in use.

You can explicitly reuse a port using the SO_REUSEADDR socket option and can explicitly bind to the same port. This works only if any port is listening (you can not reuse the listening port), and if you connect each socket to another remote address.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -