📑 Table of Contents

A Unix domain socket (UDS), also called a local socket or inter-process communication (IPC) socket, is a communication endpoint used for data exchange between processes running on the same Unix or Unix-like operating system.

The term Unix domain socket refers to the domain argument value AF_UNIX passed to the system call that creates the socket. The same communication domain can also be selected with AF_LOCAL.[1]

Valid type argument values for a UDS are:[1]

  • SOCK_STREAM (compare to TCP) – a stream-oriented socket
  • SOCK_DGRAM (compare to UDP) – a datagram-oriented socket that preserves message boundaries; on most Unix implementations, Unix domain datagram sockets are reliable and do not reorder datagrams
  • SOCK_SEQPACKET (compare to SCTP) – a connection-oriented sequenced-packet socket that preserves message boundaries and delivers messages in the order sent

The UDS facility is a standard component of a POSIX operating system.

The API for a UDS is similar to that of an Internet socket, but instead of using an underlying network protocol, communication takes place entirely within the operating system kernel. A UDS may use the file system as its address namespace. Some operating systems, such as Linux, provide additional namespaces. Processes refer to a UDS through a file system inode, allowing two processes to communicate by opening the same socket.

In addition to sending data, processes can pass file descriptors over a UDS connection by using the sendmsg() and recvmsg() system calls. This allows one process to grant another process access to a file descriptor that it would not otherwise be able to use.[2][3] This can be used to implement a rudimentary form of capability-based security.[4]

See also

edit
  • Network socket – Software-based endpoint of network communications
  • Berkeley sockets – Inter-process communication API
  • Pipeline (Unix) – Mechanism for inter-process communication using message passing
  • Netlink – Linux kernel interface for inter-process communication between processes

References

edit
  1. ^ a b "Linux Programmer's Manual (unix - sockets for local interprocess communication)". 30 April 2018. Retrieved 22 February 2019.
  2. ^ "Archive of the "Postfix Discussions" mailing list". 30 September 2000. Archived from the original on 18 May 2013. Retrieved 29 September 2014.
  3. ^ "Linux man page - cmsg(3): access ancillary data". Retrieved 9 October 2018.
  4. ^ ""Secure Programming for Linux and Unix HOWTO", Section 3.4 "Sockets and Network Connections"". dwheeler.com. David A. Wheeler. 22 August 2004. Retrieved 29 September 2014.
edit

📚 Artikel Terkait di Wikipedia

Inter-process communication

named pipes, Local Procedure Call, MailSlots, Message loop, MSRPC, .NET Remoting, and Windows Communication Foundation (WCF) Novell's SPX POSIX mmap, message

Berkeley sockets

Berkeley sockets is an application programming interface (API) for Internet domain sockets and Unix domain sockets, used for inter-process communication (IPC)

C POSIX library

The C POSIX library is a specification of a C standard library for POSIX systems. It was developed at the same time as the ANSI C standard. Some effort

Shared memory

the function shm_open from sys/mman.h. POSIX interprocess communication (part of the POSIX:XSI Extension) includes the shared-memory functions shmat,

Plan 9 from Bell Labs

device access and remote inter-process communication cleanly, even though it could have, had the preexisting UNIX domain sockets (which "can essentially

Thread (computing)

space processes interact only through system-provided inter-process communication mechanisms context switching between threads in the same process typically

Systemd

traditional startup sequence approach. For inter-process communication (IPC), systemd makes Unix domain sockets and D-Bus available to the running daemons

Parallel computing

costs associated with merging data from multiple processes. Specifically, inter-process communication and synchronization can lead to overheads that are