What is a socket, physically?

前端 未结 3 1741
醉梦人生
醉梦人生 2021-01-30 07:32

I always prefer the pyhsical meaning of a programming concept to its logical meaning. So here comes this question.

As I review the socket programming paradigm, I noticed

3条回答
  •  死守一世寂寞
    2021-01-30 07:57

    My 2 cents worth:

    A socket is basically consistent of a source IP, source Port, destination IP and destination Port. (Physically, it really isn't anything, this is a software based concept) This way the operating system can tell which Application (through it's port number) needs to receive the packets or is sending out the packets.

    The network stack (TCP/IP or OSI model) is implemented differently depending on your OS. If you want to learn more how packets are transferred and processed you study the OSI model or TCP/IP stack. This will tell you what happens to information as it leaves your application to be sent across a network.

    The OS deals with handling the packets, so if you're a programmer, as said before, you're normally not interested in these details.

    If you're curious and want to know just like I do, I suggest you start up and reading. :)

提交回复
热议问题