A Unix domain socket is an endpoint that lets processes on the same machine communicate through the socket API. It uses the AF_UNIX address family, also called AF_LOCAL on Linux; unlike AF_INET and AF_INET6, it is not an Internet address family.
How does a Unix domain socket work?
Processes exchange data by communicating through socket endpoints addressed locally rather than through an IP address. The Linux unix(7) manual describes the family as a way for processes on the same machine to communicate. A Unix domain socket is therefore an IPC mechanism, not a way to connect directly to a remote machine.
As an Amazon Associate I earn from qualifying purchases.
The socket API offers different communication types. The type determines whether the application works with a byte stream or messages, and whether communication is connection-oriented.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →| Socket type | Communication behavior | What the application should account for |
|---|---|---|
SOCK_STREAM |
Connection-oriented byte stream | There are no built-in message boundaries, so the application must define framing if it needs to separate messages. |
SOCK_DGRAM |
Datagrams preserve message boundaries. | The Linux manual describes Unix-domain datagrams as reliable and unordered in its documented context; do not assume identical guarantees on every operating system. |
SOCK_SEQPACKET |
Connection-oriented communication that preserves message boundaries and delivers messages in order. | Check support on the target operating system. The Linux manual says Linux has supported this type since Linux 2.6.4. |
These types suit different communication contracts: a continuous stream of bytes, independent messages, or ordered messages over a connection. For platform-specific behavior, consult the target system’s documentation as well as Linux’s unix(7) and socket(2) manuals.
What address does a Unix domain socket use?
Unix domain socket addresses can be unnamed or named. On Linux, a named address can use a filesystem pathname or the abstract namespace.
Filesystem pathname
A pathname socket appears as a socket entry in the filesystem. Linux documents that the caller must remove the entry when it is no longer needed. Filesystem operations can manage its ownership and permissions, making the pathname and the surrounding filesystem permissions relevant to access control.
Rank #2
- The Unix Programming Environment (Prentice-Hall Software Series)
- Product Type: ABIS_BOOK
- Pearson
Linux abstract namespace
An abstract address starts with a null byte in sun_path and is independent of filesystem pathnames. It is a Linux-specific, nonportable extension. It has no filesystem permission controls, so a design using it cannot rely on pathname ownership or permissions in the same way. For portable code, use the pathname form where supported and check each platform’s sockaddr_un layout and address-length rules.
Free tools Windows power users keep installed
One-click scans. No signup required.
Can Unix domain sockets pass file descriptors or credentials?
Yes. Unix domain sockets can carry ancillary data, including file descriptors and process credentials. Passing an open file descriptor can let one process hand another access to an already-open resource without communicating through an Internet socket. Credential transfer may also be useful in local service designs, but neither capability is a universal authentication guarantee: the available APIs and rules depend on the operating system and socket type. The Linux unix(7) manual documents these ancillary-data capabilities.
Rank #3
- Used Book in Good Condition
When should you choose a Unix domain socket?
Consider the requirements of the processes and their communication contract rather than assuming one IPC mechanism is always best. A Unix domain socket is a candidate when both endpoints run on one machine and socket-style communication, message handling, or ancillary data fits the design.
- Locality: If endpoints must communicate across machines, a local address family is not sufficient; choose a network-capable mechanism.
- Framing: For
SOCK_STREAM, define how the receiver identifies message boundaries. Datagram and sequenced-packet types preserve boundaries, with ordering and connection behavior differing by type. - Address portability: A filesystem pathname is generally the more portable Unix-domain form; Linux abstract addresses are not portable.
- Access control: A pathname can use filesystem ownership and permissions. Abstract sockets lack those filesystem controls, so plan access control accordingly.
- Descriptor passing: If one process needs to transfer an open file descriptor to another, check whether the target platform’s socket APIs support the required ancillary data.
These properties distinguish Unix domain sockets from alternatives such as TCP loopback or pipes, but they do not establish a blanket speed advantage. Choose based on locality, framing, ordering, portability, authorization, and descriptor-passing needs.
Quick Recap
Rank #4
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




