Does Socket IO involve Disk IO?

前端 未结 3 560
旧巷少年郎
旧巷少年郎 2021-02-05 14:45

If one process sends data through a socket to another process on the same machine how likely is it that a disk read/write will occur during transmission? There seems to be a soc

3条回答
  •  一整个雨季
    2021-02-05 14:52

    In the POSIX model, as well as many other kernels, files are not only in disks. Instead, every device is represented by a "special file". They live in directories or some sort of namespace, but accessing them is not disk access, even if they are placed in a directory on disk.

    If you have memory pressure, then it's possible for some of your data buffers to get swapped out. But this has nothing to do with the "file" nature of devices. It's just using the disk as additional RAM.

    So "Yes, socket I/O is file I/O, but not disk read/write."

提交回复
热议问题