A Unix domain socket (UDS), a.k.a. local socket, a.k.a.
inter-process communication
In computer science, interprocess communication (IPC) is the sharing of data between running Process (computing), processes in a computer system. Mechanisms for IPC may be provided by an operating system. Applications which use IPC are often cat ...
(IPC) socket, is a
communication endpoint
A communication endpoint is a type of Node (networking), communication network node. It is an interface exposed by a communicating party or by a communication channel. An example of the latter type of a communication endpoint is a publish–subscr ...
for exchanging data between processes executing in the same
Unix
Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
or
Unix-like
A Unix-like (sometimes referred to as UN*X, *nix or *NIX) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Uni ...
operating system.
The name, ''Unix domain socket'', refers to the
domain
argument value
AF_UNIX
that is passed to the function that creates a socket
system resource. The same communication domain is also selected by
AF_LOCAL
.
Valid
type
argument values for a UDS are:
*
SOCK_STREAM
(compare to
TCP) – for a stream-oriented socket
*
SOCK_DGRAM
(compare to
UDP) – for a datagram-oriented socket that preserves message boundaries (as on most UNIX implementations, UNIX domain datagram sockets are always reliable and don't reorder datagrams)
*
SOCK_SEQPACKET
(compare to
SCTP
The Stream Control Transmission Protocol (SCTP) is a computer networking communications protocol in the transport layer of the Internet protocol suite. Originally intended for Signaling System 7 (SS7) message transport in telecommunication, the ...
) – for a sequenced-packet socket that is connection-oriented, preserves message boundaries, and delivers messages in the order that they were sent
The UDS facility is a standard component of a
POSIX
The Portable Operating System Interface (POSIX; ) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines application programming interfaces (APIs), along with comm ...
operating system
An operating system (OS) is system software that manages computer hardware and software resources, and provides common daemon (computing), services for computer programs.
Time-sharing operating systems scheduler (computing), schedule tasks for ...
.
The
API
An application programming interface (API) is a connection between computers or between computer programs. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how to build ...
for a UDS is similar to that of an
Internet socket, but rather than using an underlying network protocol, all communication occurs entirely within the operating system
kernel. A UDS may use the file system as its address
name space. Some operating systems, like
Linux
Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
, offer additional namespaces. Processes reference a UDS as a file system
inode
An inode (index node) is a data structure in a Unix-style file system that describes a file-system object such as a file or a directory. Each inode stores the attributes and disk block locations of the object's data. File-system object attribu ...
, so two processes can communicate by opening the same socket.
In addition to sending data, processes may send
file descriptor
In Unix and Unix-like computer operating systems, a file descriptor (FD, less frequently fildes) is a process-unique identifier (handle) for a file or other input/output resource, such as a pipe or network socket.
File descriptors typically h ...
s across a UDS connection using the
sendmsg()
and
recvmsg()
system calls. This allows the sending processes to grant the receiving process access to a file descriptor for which the receiving process otherwise does not have access.
This can be used to implement a rudimentary form of
capability-based security.
See also
*
*
*
*
References
External links
*
*
*
*
*
ucspi-unix UNIX-domain socket client-server command-line tools
{{Use dmy dates, date=January 2019
Network socket
Unix
fr:Berkeley sockets#Socket unix