On Wednesday 02 February 2005 12:52, Davi de Castro Reis wrote:
No new port. The port is the same of the socket you called listen(2) at.
and uses the client's source
port that was assigned by the client's kernel.
Yes. That is correct.
In the whole process, there are only two ports involved. One given by the kernel (client), the other programatically set by the server. C code for simple server and simple client in the end of the message.
[]s Davi de Castro Reis
//Server code
c = accept(s, (struct sockaddr *)(&newaddr), &newaddr_len);
//Check port assigned by the kernel in the client side fprintf(stderr, "Client port: %u\n", ntohs(newaddr.sin_port));
//Client code
c = connect(s, (struct sockaddr *)&addr, sizeof(addr));
fprintf(stderr, "Server port: %u\n", ntohs(addr.sin_port));
Server port: 1025 -- This is because this is from the structure you set up.
Client port: 35609 -- This is the port assigned by the kernel.
Take a look at the actual packets. You will see in the packet, an IP address
and a port address. I don't have the time today since I have a 4 hour
meeting in 5 minutes.
--
Jerry Feldman