This is not true. The source port is assigned by the kernel, and the destination port is programatically set by the server. They do not change after a connect()/accept(). Take a look at netstat or tcpdump output. There are _applications_ that do work like this, like ftp. But, by some reason, they teach that every tcp connection works this way in the university. That is what I said. I think you are confused. First, the client chooses the destination IP address and the destination
On Wednesday 02 February 2005 09:48, Davi de Castro Reis wrote:
port. The Server chooses the the port on which it listens.
So, for the client, the destination port (eg. for telnet is 23) and the
source port is assigned by the kernel.
On the server side, the accept system call creates a new socket, and the
source and destination port are both assigned by the kernel. Since the
listen socket is bound (see bind(2)) to the original port, the new socket
created by the accept(2) call on the server side. It uses a new port
assigned by the kernel as its receiving port, and uses the client's source
port that was assigned by the client's kernel.
In the case where a NAT is involved, there is a translation of the ip
address and port on the NAT's LAN.
--
Jerry Feldman