On Thu, 15 Jun 2006, 15:34:27 +0200, Curt, WE7U wrote:
On Thu, 15 Jun 2006, Per Jessen wrote:
I'm mostly curious - wath are the pros and cons of using a local UNIX socket vs. an INET socket? E.g. having a daemon listen on /var/lib/xxx/yyy.soc instead of localhost:nnnnn ? (it is assumed that everyone involved will have the choice of using either one).
Any likely performance impacts (positive or negative)?
One downside to using UNIX sockets: You have to use them on the same machine. You cannot connect between machines with them.
Upside to using INET sockets: You can use them on the one machine or connect across machines.
Most people program with the INET sockets just in case they ever need to connect between machines.
I'm not well-versed in whether there are any performance or security issues of one over the other.
As Curt pointed out, UNIX sockets can only be used if you are sure, communication will only be on the local machine. But performance will actually *really* benefit if you're using UNIX vs INET sockets: I ran a small client/server combo which just exchanges messages of length 8 KiB; here are the results: UNIX sockets on local machine: $ ./lclient dummy MBytes per sec. : 262.23 MBytes per sec. : 284.34 MBytes per sec. : 293.61 MBytes per sec. : 307.26 MBytes per sec. : 355.33 INET sockets between two machines connected via GigE: $ ./gclient saturn MBytes per sec. : 99.18 MBytes per sec. : 94.13 MBytes per sec. : 102.68 MBytes per sec. : 103.58 MBytes per sec. : 103.69 MBytes per sec. : 97.92 MBytes per sec. : 103.15 But remember, there are several items to be considered: - bandwidth/throughput of the local system - bandwidth/throughput/latency of your network - resulting load on the system(s) If you know communication will always be local to the machines the applications are running on, use UNIX sockets; it might (actually it will!) result in higher load on the system, though, as both client and server are running on the same system. HTH, cheers. l8er manfred