What is the difference between a port and a socket?

后端 未结 30 2096
旧巷少年郎
旧巷少年郎 2020-11-22 14:31

This was a question raised by one of the software engineers in my organisation. I\'m interested in the broadest definition.

30条回答
  •  再見小時候
    2020-11-22 15:20

    The port was the easiest part, it is just a unique identifier for a socket. A socket is something processes can use to establish connections and to communicate with each other. Tall Jeff had a great telephone analogy which was not perfect, so I decided to fix it:

    • ip and port ~ phone number
    • socket ~ phone device
    • connection ~ phone call
    • establishing connection ~ calling a number
    • processes, remote applications ~ people
    • messages ~ speech

提交回复
热议问题