UNIX Domain Socket (Socket)

Return to Glossary

A UNIX Domain Socket (Socket) or Inter-Process Communication Socket (IPC socket) is a data communications endpoint for exchanging data between processes executing on the same host operating system. Valid socket types in the UNIX domain are:

SOCK_STREAM (compare to Transmission Control Protocol (TCP)) – for a stream-oriented socketSOCK_DGRAM (compare to dido:public:ra:xapend:xapend.a_glossary:u: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 Stream Control Transmission Protocol (SCTP)) – for a Sequenced Packet Exchange (SPX) that is connection-oriented, preserves message boundaries, and delivers messages in the order that they were sentThe UNIX domain socket facility is a standard component of Portable Operating System Interface (POSIX) operating systems.

The API for UNIX Domain Sockets 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. UNIX Domain Sockets may use the file system as their address namespace. (Some operating systems, like Linux, offer additional namespaces.) Processes reference UNIX Domain Sockets as file system inodes, so two processes can communicate by opening the same socket.

In addition to sending data, processes may send file descriptors across a UNIX Domain Socket 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. For example, this allows the Clam AntiVirus scanner to run as an unprivileged daemon on Linux and BSD, yet still read any file sent to the daemon's Unix domain socket. Source: URIhttps://en.wikipedia.org/wiki/Unix_domain_socket