What is supposed to happen if a server wants to bind() to a port
which happens to already be in use by a TCP session?
Since the TCP session is identified by the quad source address,
source port, destination address, destination port, that should not
limit the ability to bind() to that port. But is that what
really happens on real systems?
What is supposed to happen if a server wants to bind() to a port
which happens to already be in use by a TCP session?
Since the TCP session is identified by the quad source address,
source port, destination address, destination port, that should not
limit the ability to bind() to that port. But is that what
really happens on real systems?
On most systems, you will only be able to successfully bind to a port
not otherwise being used. There may be ways to override a bit (SO_REUSEADDRESS/PORT), but those often don't do what you want.
In general ephemeral ports should be coming out of a different range
than statically allocated ports, and so should not conflict, OTOH,
OS's have not been consistent which ranges get assigned to what - old Windows, for example, used to use 1025-5000 for ephemeral port, but
now uses 49152+, as do most *nix).
On Thursday, April 13, 2017 at 5:24:34 PM UTC-7, robert...@yahoo.com wrote:
(snip, I wrote)
What is supposed to happen if a server wants to bind() to a port
which happens to already be in use by a TCP session?
Since the TCP session is identified by the quad source address,
source port, destination address, destination port, that should not
limit the ability to bind() to that port. But is that what
really happens on real systems?
On most systems, you will only be able to successfully bind to a port
not otherwise being used. There may be ways to override a bit
(SO_REUSEADDRESS/PORT), but those often don't do what you want.
Interesting. I was suspecting that it wouldn't cause a conflict,
but didn't know. It turns out that the question came from someone misunderstanding how their program worked.
In general ephemeral ports should be coming out of a different range
than statically allocated ports, and so should not conflict, OTOH,
OS's have not been consistent which ranges get assigned to what - old
Windows, for example, used to use 1025-5000 for ephemeral port, but
now uses 49152+, as do most *nix).
Presumably that works unless one host wants many thousands of connections
to one port on a server. Rare, but not impossible.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 307 |
Nodes: | 16 (2 / 14) |
Uptime: | 93:14:41 |
Calls: | 6,849 |
Files: | 12,352 |
Messages: | 5,414,741 |