TCP standard has "simultaneous open" feature.
The implication of the feature, client trying to connect to local port, when the port is from ephemeral range, can occasionally connect to itself (see here).
So client think it's connected to server, while it actually connected to itself. From other side, server can not open its server port, since it's occupied/stolen by client.
I'm using RHEL 5.3 and my clients constantly tries to connect to local server. Eventually client connects to itself.
I want to prevent the situation. I see two possible solutions to the problem:
- Don't use ephemeral ports for server ports. Agree ephemeral port range and configure it on your machines (see ephemeral range)
- Check connect() as somebody propose here.
What do you thinks? How do you handle the issue?
P.S. 1
Except of the solution, which I obviously looking for, I'd like you to share your real life experience with the problem.
When I found the cause of the problem, I was "astonished" on my work place people are not familiar with it. Polling server by connecting it periodically is IMHO common practice, so how it's that the problem is not commonly known.
See Question&Answers more detail:os