tags:

views:

55

answers:

1

On unix system when you call the accept system call, does the newly created socket have a different port number from the listening socket?

+5  A: 

No, it has the same port number.

TCP/IP connections are differentiated by their source and destination ips, and source and destination port numbers, so each connection to the same port from the same "client" on the "recipient" will have the same port on the "recipient," but a unique* port on the "client."

*Unique, at least, from the perspective of the "recipient."

WhirlWind
Reason for downvote?
WhirlWind
Because I thought, it was wrong. But the more I think about it... I was wrong. Sorry for that. (undownvoted).
Daniel
Thank you i was looking for a confirmation, because I had a discussion, and I think we confused sockets with connection. From my point of view, a connection is unique, but the handshake is handled in the "listening socket" and then the control passes to the "private socket".
Gainder