What is the difference between a port and a socket?

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

    A socket is a special type of file handle which is used by a process to request network services from the operating system. A socket address is the triple: {protocol, local-address, local-process} where the local process is identified by a port number.

    In the TCP/IP suite, for example:

    {tcp, 193.44.234.3, 12345}

    A conversation is the communication link between two processes thus depicting an association between two. An association is the 5-tuple that completely specifies the two processes that comprise a connection: {protocol, local-address, local-process, foreign-address, foreign-process}

    In the TCP/IP suite, for example:

    {tcp, 193.44.234.3, 1500, 193.44.234.5, 21}

    could be a valid association.

    A half-association is either: {protocol, local-address, local-process}

    or

    {protocol, foreign-address, foreign-process}

    which specify each half of a connection.

    The half-association is also called a socket or a transport address. That is, a socket is an end point for communication that can be named and addressed in a network. The socket interface is one of several application programming interfaces (APIs) to the communication protocols. Designed to be a generic communication programming interface, it was first introduced by the 4.2BSD UNIX system. Although it has not been standardized, it has become a de facto industry standard.

提交回复
热议问题