What is the difference between a port and a socket?

后端 未结 30 2128
旧巷少年郎
旧巷少年郎 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:05

    A socket consists of three things:

    1. An IP address
    2. A transport protocol
    3. A port number

    A port is a number between 1 and 65535 inclusive that signifies a logical gate in a device. Every connection between a client and server requires a unique socket.

    For example:

    • 1030 is a port.
    • (10.1.1.2 , TCP , port 1030) is a socket.

提交回复
热议问题