Do TCP client ports and TCP server ports have the same address space?
Answer: "It depends" (OS and socket options).
On Linux with SO_REUSEADDR
both sockets, the exact situation is possible:
$ sudo netstat -panl |grep 12300
tcp 0 0 127.0.0.1:12300 0.0.0.0:* LISTEN 3591/nc
tcp 0 0 127.0.0.1:12300 127.0.0.1:25 ESTABLISHED 3547/nc
tcp 0 0 127.0.0.1:25 127.0.0.1:12300 ESTABLISHED 3548/exim4
... but only when the client gets there first. When the server is already listening, the same port cannot be bound by the client (and it will never be automatically assigned to the client, IIRC).
On Windows with or without SO_REUSEADDR
port is a port and is bind
not working (whether it is the server or client that did it in the first place).
source to share
Not. Port - port.
IT SAID: Collisions are rarely there because usually servers start before the client asks for an undefined port (i.e. the client never sets a port number, his machine takes a free one).
And there are predefined ports for most servers.
http://www.webopedia.com/quick_ref/portnumbers.asp http://www.ietf.org/rfc/rfc1700.txt?number=1700
And the ranges:
http://www.tcpipguide.com/free/t_TCPIPApplicationAssignmentsandServerPortNumberRang-2.htm
As you can see, the registerd ports go to 49151 and from there they are reserved for dynamic use. So client ports usually come from that 49152 range upwards, which services shouldn't be used.
source to share