Accept() method and new socket
On unix system when you call the accept system call, does the newly created socket have a differen开发者_运维百科t port number from the listening socket?
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."
精彩评论