Unix ___domain socket: Difference between revisions

Content deleted Content added
use Annotated link
name comes from AF_UNIX; Unix (not just any OS); singular over plural; if we're going to define an acronym might as well use it
Line 1:
{{short description|SocketCommunications endpoint for exchanging data between processes executing onin the same operating system}}
A '''Unix ___domain socket''' ('''UDS'''), ora.k.a. '''IPC socket''' ([[inter-process communication]] (IPC) socket''', is a data [[communication endpoint|communications endpoint]] for exchanging data between processes executing onin the same host[[Unix]] or [[Unix-like]] operating system. It is also referred to by its address family <code>AF_UNIX</code>.
 
The name, ''Unix ___domain socket'', refers to the <code>___domain</code> argument value <code>AF_UNIX</code> that is passed to the function that creates a socket [[system resource]]. The communication ___domain is also selected by <code>AF_LOCAL</code>. <ref name="man-unix-sockets"></ref>
==Sockets==
 
Valid socket<code>type</code> typesargument invalues thefor UNIXa ___domainUDS are:<ref name="man-unix-sockets">{{cite web
| url = http://man7.org/linux/man-pages/man7/unix.7.html
| date = 30 April 2018
Line 12 ⟶ 13:
* <code>SOCK_DGRAM</code> (compare to [[User Datagram Protocol|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)
* <code>SOCK_SEQPACKET</code> (compare to [[SCTP]]) – for a sequenced-packet socket that is connection-oriented, preserves message boundaries, and delivers messages in the order that they were sent
The Unix ___domain socket facility is a standard component of [[POSIX]] [[operating system]]s.
 
The Unix ___domain socketUDS facility is a standard component of a [[POSIX]] [[operating system]]s.
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 (operating system)|kernel]]. Unix ___domain sockets may use the file system as their address [[name space]]. (Some operating systems, like [[Linux]], offer additional namespaces.) Processes reference Unix ___domain sockets as file system [[inode]]s, so two processes can communicate by opening the same socket.
 
The [[API]] for Unixa ___domain socketsUDS 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 (operating system)|kernel]]. UnixA ___domain socketsUDS may use the file system as theirits address [[name space]]. (Some operating systems, like [[Linux]], offer additional namespaces.) Processes reference Unixa ___domainUDS socketsas asa file system [[inode]]s, so two processes can communicate by opening the same socket.
 
In addition to sending data, processes may send [[file descriptor]]s across a Unix ___domain socketUDS connection using the <code>sendmsg()</code> and <code>recvmsg()</code> 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.<ref name="neohapsis">{{cite web |url=http://archives.neohapsis.com/archives/postfix/2000-09/1476.html |date=30 September 2000 |title=Archive of the "Postfix Discussions" mailing list |access-date=29 September 2014 |archive-url=https://web.archive.org/web/20130518084034/http://archives.neohapsis.com/archives/postfix/2000-09/1476.html |archive-date=18 May 2013 |url-status=dead |df=dmy-all}}</ref><ref name="linux-cmsg-man-page">{{cite web |url=https://linux.die.net/man/3/cmsg |title=Linux man page - cmsg(3): access ancillary data |access-date=9 October 2018 |df=dmy-all}}</ref> This can be used to implement a rudimentary form of [[capability-based security]].<ref name="wheeler-secure-linux-howto">{{cite web |url=https://www.dwheeler.com/secure-programs/Secure-Programs-HOWTO/sockets.html |title="Secure Programming for Linux and Unix HOWTO", Section 3.4 "Sockets and Network Connections" |date=22 August 2004 |website=dwheeler.com |publisher=David A. Wheeler |access-date=29 September 2014}}</ref>
 
==See also==