Performance of sockets vs pipes

后端 未结 3 363
醉话见心
醉话见心 2021-01-12 21:08

I have a Java-program which communicates with a C++ program using a socket on localhost. Can I expect to gain any performance (either latency, bandwidth, or both) by moving

相关标签:
3条回答
  • 2021-01-12 21:11

    The first google hit turned up this, which clocked NT4 and XP and found named pipes (that's what you meant, right?) to be faster on Windows.

    0 讨论(0)
  • Ken is right. Named pipes are definitely faster on Windows. On UNIX & Linux, you'd want a UDS or local pipe. Same thing, different name.

    Anything other than sockets will be faster for local communication. This includes memory mapped files, local pipes, shared memory, COM, etc.

    0 讨论(0)
  • 2021-01-12 21:21

    For local processes communication pipes are definitely faster than sockets. There is a benchmark.

    I think even though socket is flexible but it can also lead to bad code design. While using pipe it enforces you to design the architecture of your project like which process should be the parent which should be the children and how they cooperate(this will determine how pipes are established) and assign different functionality to processes. Your project design this way will have hierarchical structure and easy to maintain.

    0 讨论(0)
提交回复
热议问题