When doing IPC using TCP/IP sockets using the loopback address, do common networking stacks skip framing the message in lower-level PDUs?

后端 未结 3 864
迷失自我
迷失自我 2021-02-04 07:33

In some environments such as Java, it\'s natural to use TCP/IP sockets to pass messages between processes on the same host using the \'localhost\' address (127.0.0.1 in IPv4, or

3条回答
  •  不知归路
    2021-02-04 08:11

    Specifically in linux when packets are transmitted on the loopback interface the kernel raises a "software" interrupt for each packet. From that point on the packet reception is identical to the packet reception flow for a physical device. So you are correct in your assumption that communication over the loopback interface would be much slower than alternate IPC mechanisms such as unix sockets.

    I guess the kernel code path can be optimized. For e.g., we could call the receive code path directly from the transmit code path of loopback interface.

提交回复
热议问题