unix domain sockets vs. internet sockets

Peter Pentchev roam at ringlet.net
Thu Feb 24 23:21:10 PST 2005


On Fri, Feb 25, 2005 at 09:02:45AM +0200, Baris Simsek wrote:
> Hi, 
> 
> I am coding a daemon program. I am not sure about which type of
> sockets i should use. Could you compare ip sockets and unix domain
> sockets?  My main criterions are performance and protocol load.

The main point you should be thinking about is - should your daemon be
accessible by clients running on remote machines?  If so, Unix-domain
sockets are *definitely* not what you want, since they are, by design,
limited to connections on the same machine.  This is actually what makes
them a lot more efficient to use.

However, it would not be too hard to write your program so it is pretty
much independent of the type of sockets used - that's the point of the
Berkeley *sockets* intreface :)  If you drive carefully around the very
few things you can do *only* with Unix-domain sockets (for instance,
credential passing), and the very few things you can do *only* with
Internet-domain sockets (e.g. accept filters), and you handle the
address size/representation issue carefully (which in theory you should
anyway, what with IPv6 just around the corner... it seems ;), then your
program should have no trouble with listening on both/either type of
socket.  Actually, a lot of programs do that already, getting the best
of both worlds - the efficiency of Unix-domain sockets for local clients
and the ease of use of Internet-domain sockets for remote connections.

> What are the differences between impelementations of them at kernel
> level? 

I'll have to let someone else answer that one :)

G'luck,
Peter

-- 
Peter Pentchev	roam at ringlet.net    roam at cnsys.bg    roam at FreeBSD.org
PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
This sentence contains exactly threee erors.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-performance/attachments/20050225/634da64a/attachment.bin


More information about the freebsd-performance mailing list