开发者

Why to use local pipes instead of sockets for programs communication inside one computer?

开发者 https://www.devze.com 2023-01-03 12:28 出处:网络
Why to use local pipes instead of sockets for programs communication inside one computer? Has Any one FRESH stats on who is faster and how nmuch, what is more sequre or less?

Why to use local pipes instead of sockets for programs communication inside one computer? Has Any one FRESH stats on who is faster and how nmuch, what is more sequre or less?

I have found a wary old and strange and scary one... http://home.iae.nl/users/mhx/pipes&socks.html

There is a noticeable difference in performance between sockets and named pipes.
Benchmark 1: 20 Mbytes copied between two iForths on machine 1; 
Benchmark 2: 20 Mbytes copied from an iForth on machine 2 to an iForth on machine 1.

Systems for sock test: Windows XP Pro, running on (1) an Intel PIV 3GHz/1GB and (2) an Intel Core 2 Duo 2.66 GHz/2GB. The PC's were networked using motherboard Realte开发者_如何学Pythonk network adapters (100 Mbit/s). 
Systems for npipe test: Windows NT 4.0, running on (1) an Intel Pentium 166MHz/48MB and (2) an Intel Pentium 200MHz/48MB. The PC's were networked using cheap NE2000 clones (10 Mbit/s).

benchmark  | process A read | process B write
===========+================+================
sock  bm 1 |    72 MB/sec   |   732 MB/sec
sock  bm 2 |  11.5 MB/sec   | 2.857 GB/sec
npipe bm 1 |    15 MB/sec   |    15 MB/sec
npipe bm 2 |   715 KB/sec   |   715 KB/sec

And here is some strange info (at least for me - windows user)


Pipes should always be faster as they completely bypass the network stack on the host operating system. Pipes are thought to be more secure as they do not listen for data from untrusted remote computers (although sockets can also be configured to only listen on the loop-back adapter and thereby avoid listening to remote computers). Named pipes are less flexible than sockets since they do not allow network communication. In either case security is still related to how well you write code. It is possible to write a pipes based application that is less secure than a socket based application.

As for how much faster one is than another that will depend on your hardware and operating system.

0

精彩评论

暂无评论...
验证码 换一张
取 消