What is a socket, physically?

前端 未结 3 1737
醉梦人生
醉梦人生 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 08:09

    Are you familiar with the OSI model? bind() specifies the local IP address and port (layer 4) to use, so when the packet is physically sent out, it specifies that IP address as the sender, and connect() specifies the remote IP address and port to physically place in those packets.

    As an aside, a lot of programming is pure "logic", and doesn't really have a "physical" meaning, unless by "physical" you actually mean "implementation detail", which will vary from platform to platform. If you're actually asking about the physical implementation meaning how "meaning" is transformed into electrical signals, you would probably be happier as a computer engineer than as a programmer.

提交回复
热议问题