Unix ___domain socket: Difference between revisions

Content deleted Content added
Reverted 3 edits by 94.21.161.60 (talk): Not a reliable source
m MOS:AKA, MOS:BOLDLINKAVOID, MOS:BOLDSYN, delete incorrect commas
 
(9 intermediate revisions by 4 users not shown)
Line 1:
{{shortShort description|MechanismCommunications endpoint for exchanging data exchange between processes executing on the same host}}
InA [[Client–server'''Unix model|client-server___domain computing]]socket''' ('''UDS'''), a'''local socket'''Unix, ___domainor '''inter-process communication''' ('''IPC''') '''socket''' is a [[Berkeleycommunication sockets|Berkeley socketendpoint]] thatfor allows[[inter-process datacommunication|exchanging to be exchangeddata between two [[Process (computing)|processes]] [[Execution (computing)|executing]] onin the same [[Unix]] or [[Unix-like]] hostoperating computersystem.<ref name="lpi-p1149_quote">{{cite book
|title=The Linux Programming Interface
|last=Kerrisk
|first=Michael
|publisher=No Starch Press
|year=2010
|quote=Sockets are a method of IPC that allow data to be exchanged between applications, either on the same host (computer) or on different hosts connected by a network.
|isbn=978-1-59327-220-3
|page=1149}}</ref> This is similar to an ''Internet ___domain socket'' that allows data to be exchanged between two processes executing on different host computers.
 
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 same communication ___domain is also selected by <code>AF_LOCAL</code>. <ref name="man-unix-sockets"></ref>
Regardless of the ''range of communication'' (same host or different host),<ref name="lpi-p1150">{{cite book
|title=The Linux Programming Interface
|last=Kerrisk
|first=Michael
|publisher=No Starch Press
|year=2010
|isbn=978-1-59327-220-3
|page=1150}}</ref> Unix [[computer program]]s that perform ''socket'' [[Inter-process communication|communication]] are similar. The only ''range of communication'' difference is the method to convert a name to the address parameter needed to ''bind'' the socket's connection. For a ''Unix ___domain socket'', the name is a <code>/[[Path (computing)|path]]/[[filename]]</code>. For an ''Internet ___domain socket'', the name is an <code>[[IP address]]:[[Port (computer networking)|Port number]]</code>. In either case, the name is called an ''address''.<ref name="lpi-p1150_quote">{{cite book
|title=The Linux Programming Interface
|last=Kerrisk
|first=Michael
|publisher=No Starch Press
|year=2010
|isbn=978-1-59327-220-3
|quote=The server binds its socket to a well-known address (name) so that clients can locate it.
|page=1150}}</ref>
 
Valid <code>type</code> argument values for a UDS are:<ref name="man-unix-sockets">{{cite web
Two processes may communicate with each other if each obtains a socket. The server process ''binds'' its socket to an ''address'', opens a ''listen'' channel, and then continuously [[While loop|loops]]. Inside the loop, the server process is put to sleep while waiting to ''accept'' a client connection.<ref name="unp-p14_quote">{{cite book
|title=Unix Network Programming
|last1=Stevens
|first1=Richard W.
|last2=Fenner
|first2=Bill
|last3=Rudoff
|first3=Andrew M.
|publisher=Pearson Education
|year=2004
|edition=3rd
|isbn=81-297-0710-1
|quote=Normally, the server process is put to sleep in the call to ''accept'', waiting for a client connection to arrive and be accepted.
|page=14}}</ref> Upon ''accepting'' a client connection, the server then executes a [[read (system call)|read]] [[system call]] that will [[Blocking (computing)|block wait]]. The client ''connects'' to the server's socket via the server's ''address''. The client process then [[write (system call)|writes]] a [[String (computer science)|message]] for the server process to read. The application's [[algorithm]] may entail multiple read/write interactions. Upon completion of the algorithm, the client executes <code>exit()</code><ref name="lpi-p1169">{{cite book
|title=The Linux Programming Interface
|last=Kerrisk
|first=Michael
|publisher=No Starch Press
|year=2010
|isbn=978-1-59327-220-3
|page=1169}}</ref> and the server executes <code>close()</code>.<ref name="lpi-p1159">{{cite book
|title=The Linux Programming Interface
|last=Kerrisk
|first=Michael
|publisher=No Starch Press
|year=2010
|isbn=978-1-59327-220-3
|page=1159}}</ref>
 
For a ''Unix ___domain socket'', the socket's address is a <code>/path/filename</code> identifier. The server will create <code>/path/filename</code> on the [[file system|filesystem]] to act as a [[File_locking#Lock_files|lock file]] [[Semaphore (programming)|semaphore]]. No I/O occurs on this file when the client and server send messages to each other.<ref name="lpi-p1166">{{cite book
|title=The Linux Programming Interface
|last=Kerrisk
|first=Michael
|publisher=No Starch Press
|year=2010
|isbn=978-1-59327-220-3
|page=1166}}</ref>
 
==History==
Sockets first appeared in [[History_of_the_Berkeley_Software_Distribution#4BSD|Berkeley Software Distribution 4.2]] (1983).<ref name="lpi-p1149">{{cite book
|title=The Linux Programming Interface
|last=Kerrisk
|first=Michael
|publisher=No Starch Press
|year=2010
|isbn=978-1-59327-220-3
|page=1149}}</ref> It became a [[POSIX]] standard in 2000.<ref name="lpi-p1149"/> The [[application programming interface]] has been ported to virtually every Unix implementation and most other operating systems.<ref name="lpi-p1149"/>
 
==Socket instantiation==
Both the server and the client must [[Instance (computer science)|instantiate]] a ''socket'' object by executing the <code>socket()</code> [[system call]]. Its usage is<ref name="lpi-p1153">{{cite book
|title=The Linux Programming Interface
|last=Kerrisk
|first=Michael
|publisher=No Starch Press
|year=2010
|isbn=978-1-59327-220-3
|page=1153}}</ref>
<syntaxhighlight lang="c">
int socket( int ___domain, int type, int protocol );
</syntaxhighlight>
 
The <code>___domain</code> parameter should be one of the following common ''ranges of communication'':<ref name="lpi-p1151">{{cite book
|title=The Linux Programming Interface
|last=Kerrisk
|first=Michael
|publisher=No Starch Press
|year=2010
|isbn=978-1-59327-220-3
|page=1151}}</ref>
 
# Within the same host by using the [[Constant (computer programming)|constant]] <code>AF_UNIX</code>{{efn|Alternatively, <code>PF_UNIX</code> or <code>AF_LOCAL</code> may be used.<ref name="man-unix-sockets">{{cite web
| url = http://man7.org/linux/man-pages/man7/unix.7.html
| date = 30 April 2018
| title = Linux Programmer's Manual (unix - sockets for local interprocess communication)
| access-date = 22 February 2019
| df = dmy-all}}</ref> The AF stands for "Address Family", and the PF stands for "Protocol Family".}}
* <code>SOCK_STREAM</code> (compare to [[Transmission Control Protocol|TCP]]) – for a stream-oriented socket
# Between two hosts via the [[IPv4]] protocol by using the constant <code>AF_INET</code>
* <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)
# Between two hosts via the [[IPv6]] protocol by using the constant <code>AF_INET6</code>
* <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
# Within the same host or between two hosts via the [[Stream Control Transmission Protocol]] by using the constant <code>SOCK_SEQPACKET</code><ref name="man-unix-sockets"/>
 
The UDS facility is a standard component of a [[POSIX]] [[operating system]].
The ''Unix ___domain socket'' label is used when the <code>___domain</code> parameter's value is <code>AF_UNIX</code>. The ''Internet ___domain socket'' label is used when the <code>___domain</code> parameter's value is either <code>AF_INET</code> or <code>AF_INET6</code>.<ref name="lpi-p1197">{{cite book
|title=The Linux Programming Interface
|last=Kerrisk
|first=Michael
|publisher=No Starch Press
|year=2010
|isbn=978-1-59327-220-3
|page=1197}}</ref>
 
The [[API]] 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 (operating system)|kernel]]. A UDS may use the file system as its address [[name space]]. Some operating systems, like [[Linux]], offer additional namespaces. Processes reference a UDS as a file system [[inode]], so two processes can communicate by opening the same socket.
The <code>type</code> parameter should be one of two common socket types: stream or datagram.<ref name="lpi-p1151"/> A third socket type is available for experimental design: raw.
# <code>SOCK_STREAM</code> will create a stream socket. A stream socket provides a reliable, bidirectional, and [[connection-oriented communication]] channel between two processes. Data are carried using the [[Transmission Control Protocol]] (TCP).<ref name="lpi-p1151"/>
# <code>SOCK_DGRAM</code> will create a datagram socket.{{efn|A datagram ''socket'' should not be confused with a [[datagram]] [[Network packet|packet]] used in the [[network layer]].<ref name="lpi-p1183">{{cite book
|title=The Linux Programming Interface
|last=Kerrisk
|first=Michael
|publisher=No Starch Press
|year=2010
|isbn=978-1-59327-220-3
|page=1183}}</ref>}} A Datagram socket does not guarantee reliability and is [[Connectionless communication|connectionless]]. As a result, the transmission is faster. Data are carried using the [[User Datagram Protocol]] (UDP).<ref name="lpi-p1152">{{cite book
|title=The Linux Programming Interface
|last=Kerrisk
|first=Michael
|publisher=No Starch Press
|year=2010
|isbn=978-1-59327-220-3
|page=1152}}</ref>
# <code>SOCK_RAW</code> will create an [[Internet Protocol]] (IP) [[datagram]] socket. A Raw socket skips the TCP/UDP [[transport layer]] and sends the packets directly to the [[network layer]].<ref name="lpi-p1184">{{cite book
|title=The Linux Programming Interface
|last=Kerrisk
|first=Michael
|publisher=No Starch Press
|year=2010
|isbn=978-1-59327-220-3
|page=1184}}</ref>
 
In addition to sending data, processes may send [[file descriptor]]s across a UDS 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>
For a ''Unix ___domain socket'', data ([[network packet]]s) are passed between two connected processes via the [[transport layer]] — either TCP or UDP.<ref name="lpi-p1181">{{cite book
|title=The Linux Programming Interface
|last=Kerrisk
|first=Michael
|publisher=No Starch Press
|year=2010
|isbn=978-1-59327-220-3
|page=1181}}</ref> For an ''Internet ___domain socket'', data are passed between two connected processes via the transport layer and the [[Internet Protocol]] (IP) of the [[network layer]] — either TCP/IP or UDP/IP.<ref name="lpi-p1181"/>
 
The <code>protocol</code> parameter should be set to zero for stream and datagram sockets.<ref name="lpi-p1150"/> For raw sockets, the <code>protocol</code> parameter should be set to IPPROTO_RAW.<ref name="lpi-p1153">{{cite book
|title=The Linux Programming Interface
|last=Kerrisk
|first=Michael
|publisher=No Starch Press
|year=2010
|isbn=978-1-59327-220-3
|page=1153}}</ref>
 
===socket() return value===
<syntaxhighlight lang="c">
socket_fd = socket( int ___domain, int type, int protocol );
</syntaxhighlight>
 
Like the regular-file <code>[[open (system call)|open()]]</code> system call, the <code>socket()</code> system call returns a [[file descriptor]].<ref name="lpi-p1150"/>{{efn|In UNIX, [[Everything is a file]].}} The return value's suffix <code>_fd</code> stands for ''file descriptor''.
 
==Server bind to /path/filename==
After instantiating a new socket, the server binds the socket to an address. For a ''Unix ___domain socket'', the address is a <code>/path/filename</code>.
 
Because the socket address may be either a <code>/path/filename</code> or an <code>IP_address:Port_number</code>, the socket [[application programming interface]] requires the address to first be set into a structure. For a ''Unix ___domain socket'', the structure is<ref name="lpi-p1165">{{cite book
|title=The Linux Programming Interface
|last=Kerrisk
|first=Michael
|publisher=No Starch Press
|year=2010
|isbn=978-1-59327-220-3
|page=1165}}</ref>
<syntaxhighlight lang="c">
struct sockaddr_un {
sa_family_t sun_family; /* AF_UNIX */
char sun_path[ 92 ];
}
</syntaxhighlight>
 
The <code>_un</code> suffix stands for ''unix''. For an ''Internet ___domain socket'', the suffix will be either <code>_in</code> or <code>_in6</code>. The <code>sun_</code> prefix stands for ''socket unix''.<ref name="lpi-p1165"/>
 
Computer program to create and bind a stream ''Unix ___domain socket'':<ref name="lpi-p1166"/>
<syntaxhighlight lang="c">
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <assert.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/un.h>
 
/* Should be 91 characters or less. Some Unix-like are slightly more. */
/* Use /tmp directory for demonstration only. */
char *socket_address = "/tmp/mysocket.sock";
 
void main( void )
{
int server_socket_fd;
struct sockaddr_un sockaddr_un = {0};
int return_value;
 
server_socket_fd = socket( AF_UNIX, SOCK_STREAM, 0 );
if ( server_socket_fd == -1 ) assert( 0 );
 
/* Remove (maybe) a prior run. */
remove( socket_address );
 
/* Construct the bind address structure. */
sockaddr_un.sun_family = AF_UNIX;
strcpy( sockaddr_un.sun_path, socket_address );
 
return_value =
bind(
server_socket_fd,
(struct sockaddr *) &sockaddr_un,
sizeof( struct sockaddr_un ) );
 
/* If socket_address exists on the filesystem, then bind will fail. */
if ( return_value == -1 ) assert( 0 );
 
/* Listen and accept code omitted. */
}
</syntaxhighlight>
 
The second parameter for <code>bind()</code> is a pointer to <code>struct sockaddr</code>. However, the parameter passed to the function is the address of a <code>struct sockaddr_un</code>. <code>struct sockaddr</code> is a generic structure that is not used. It is defined in the [[Parameter_(computer_programming)#Parameters_and_arguments|formal parameter]] [[Declaration (computer programming)|declaration]] for <code>bind()</code>. Because each ''range of communication'' has its own ''actual parameter'', this generic structure was created as a [[Type conversion|cast]] placeholder.<ref name="lpi-p1154">{{cite book
|title=The Linux Programming Interface
|last=Kerrisk
|first=Michael
|publisher=No Starch Press
|year=2010
|isbn=978-1-59327-220-3
|page=1154}}</ref>
 
==Server listen for a connection==
After binding to an address, the server opens a listen channel to a [[Port (computer networking)|port]] by executing <code>listen()</code>. Its usage is<ref name="man_listen">{{cite web
|title=Linux manual page for listen()
|url=https://man7.org/linux/man-pages/man2/listen.2.html}}</ref>
<syntaxhighlight lang="c">
int listen( int server_socket_fd, int backlog );
</syntaxhighlight>
 
[[Snippet (programming)|Snippet]] to listen:
<syntaxhighlight lang="c">
if ( listen( server_socket_fd, 4096 ) == -1 ) assert( 0 );
</syntaxhighlight>
 
For a ''Unix ___domain socket'', <code>listen()</code> most likely will succeed and return <code>0</code>. For an ''Internet ___domain socket'', if the port is in use, <code>listen()</code> returns <code>-1</code>.<ref name="man_listen"/>
 
The <code>backlog</code> parameter sets the [[Queue (abstract data type)|queue]] size for pending connections.<ref name="lpi-p1157">{{cite book
|title=The Linux Programming Interface
|last=Kerrisk
|first=Michael
|publisher=No Starch Press
|year=2010
|isbn=978-1-59327-220-3
|page=1157}}</ref> The server may be busy when a client executes a <code>connect()</code> request. Connection requests up to this limit will succeed. If the backlog value passed in exceeds the default maximum, then the maximum value is used.<ref name="man_listen"/>
 
==Server accept a connection==
After opening a ''listen'' channel, the server enters an infinite [[While loop|loop]]. Inside the loop is a system call to <code>accept()</code>, which puts itself to sleep.<ref name="unp-p14_quote"/> The <code>accept()</code> system call will return a file descriptor when a client process executes <code>connect()</code>.<ref>{{cite web
|title=Linux manual page for accept()
|url=https://man7.org/linux/man-pages/man2/accept.2.html}}</ref>
 
Snippet to accept a connection:
<syntaxhighlight lang="c">
int accept_socket_fd;
 
while ( 1 )
{
accept_socket_fd = accept( server_socket_fd, NULL, NULL );
if ( accept_socket_fd == -1 ) assert( 0 );
 
if ( accept_socket_fd > 0 ) /* client is connected */
}
</syntaxhighlight>
 
==Server I/O on a socket==
When <code>accept()</code> returns a positive integer, the server engages in an algorithmic dialog with the client.
 
''Stream'' socket input/output may execute the regular-file system calls of <code>[[read (system call)|read()]]</code> and <code>[[write (system call)|write()]]</code>.<ref name="lpi-p1159"/> However, more control is available if a stream socket executes the socket-specific system calls of <code>send()</code> and <code>recv()</code>. Alternatively, ''datagram'' socket input/output should execute the socket-specific system calls of <code>sendto()</code> and <code>recvfrom()</code>.<ref name="lpi-p1160">{{cite book
|title=The Linux Programming Interface
|last=Kerrisk
|first=Michael
|publisher=No Starch Press
|year=2010
|isbn=978-1-59327-220-3
|page=1160}}</ref>
 
For a basic stream socket, the server receives data with <code>read( accept_socket_fd )</code> and sends data with <code>write( accept_socket_fd )</code>.
 
Snippet to illustrate I/O on a basic stream socket:
<syntaxhighlight lang="c">
int accept_socket_fd;
 
while ( 1 )
{
accept_socket_fd = accept( server_socket_fd, NULL, NULL );
if ( accept_socket_fd == -1 ) assert( 0 );
 
if ( accept_socket_fd > 0 )
{
server_algorithmic_dialog( accept_socket_fd );
}
}
 
#define BUFFER_SIZE 1024
 
void server_algorithmic_dialog(
int accept_socket_fd )
{
char input_buffer[ BUFFER_SIZE ];
char output_buffer[ BUFFER_SIZE ];
 
read( accept_socket_fd, input_buffer, BUFFER_SIZE );
 
if ( strcasecmp( input_buffer, "hola" ) == 0 )
strcpy( output_buffer, "Hola Mundo" );
else
if ( strcasecmp( input_buffer, "ciao" ) == 0 )
strcpy( output_buffer, "Ciao Mondo" );
else
strcpy( output_buffer, "Hello World" );
 
write( accept_socket_fd, output_buffer, strlen( output_buffer ) + 1 );
}
</syntaxhighlight>
 
==Server close a connection==
The algorithmic dialog ends when either the algorithm concludes or <code>read( accept_socket_fd )</code> returns <code>< 1</code>.<ref name="lpi-p1159"/> To close the connection, execute the <code>close()</code> system call:<ref name="lpi-p1159"/>
 
Snippet to close a connection:
<syntaxhighlight lang="c">
int accept_socket_fd;
 
while ( 1 )
{
accept_socket_fd = accept( server_socket_fd, NULL, NULL );
if ( accept_socket_fd == -1 ) assert( 0 );
 
if ( accept_socket_fd > 0 )
{
server_algorithmic_dialog( accept_socket_fd );
close( accept_socket_fd );
}
}
</syntaxhighlight>
 
Snippet to illustrate the end of a dialog:
<syntaxhighlight lang="c">
 
#define BUFFER_SIZE 1024
 
void server_algorithmic_dialog(
int accept_socket_fd )
{
char buffer[ BUFFER_SIZE ];
int read_count;
 
/* Omit algorithmic dialog */
 
read_count = read( accept_socket_fd, buffer, BUFFER_SIZE );
if ( read_count < 1 ) return;
 
/* Omit algorithmic dialog */
}
</syntaxhighlight>
 
==Client instantiate and connect to /path/filename==
Computer program for the client to instantiate and connect a socket:<ref name="lpi-p1169"/>
<syntaxhighlight lang="c">
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <assert.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/un.h>
 
/* Must match the server's socket_address. */
char *socket_address = "/tmp/mysocket.sock";
 
void main( void )
{
int client_socket_fd;
struct sockaddr_un sockaddr_un = {0};
int return_value;
 
client_socket_fd = socket( AF_UNIX, SOCK_STREAM, 0 );
if ( client_socket_fd == -1 ) assert( 0 );
 
/* Construct the client address structure. */
sockaddr_un.sun_family = AF_UNIX;
strcpy( sockaddr_un.sun_path, socket_address );
 
return_value =
connect(
client_socket_fd,
(struct sockaddr *) &sockaddr_un,
sizeof( struct sockaddr_un ) );
 
/* If socket_address doesn't exist on the filesystem, */
/* or if the server's connection-request queue is full, */
/* then connect() will fail. */
if ( return_value == -1 ) assert( 0 );
 
/* close( client_socket_fd ); <-- optional */
 
exit( EXIT_SUCCESS );
}
</syntaxhighlight>
 
==Client I/O on a socket==
If <code>connect()</code> returns zero, the client can engage in an algorithmic dialog with the server. The client may send stream data via <code>write( client_socket_fd )</code> and may receive stream data via <code>read( client_socket_fd )</code>.
 
Snippet to illustrate client I/O on a stream socket:
<syntaxhighlight lang="c">
{
/* Omit construction code */
return_value =
connect(
client_socket_fd,
(struct sockaddr *) &sockaddr_un,
sizeof( struct sockaddr_un ) );
 
if ( return_value == -1 ) assert( 0 );
 
if ( return_value == 0 )
{
client_algorithmic_dialog( client_socket_fd );
}
 
/* close( client_socket_fd ); <-- optional */
 
/* When the client process terminates, */
/* if the server attempts to read(), */
/* then read_count will be either 0 or -1. */
/* This is a message for the server */
/* to execute close(). */
exit( EXIT_SUCCESS );
}
 
#define BUFFER_SIZE 1024
 
void client_algorithmic_dialog(
int client_socket_fd )
{
char buffer[ BUFFER_SIZE ];
int read_count;
 
strcpy( buffer, "hola" );
write( client_socket_fd, buffer, strlen( buffer ) + 1 );
read_count = read( client_socket_fd, buffer, BUFFER_SIZE );
 
if ( read_count > 0 ) puts( buffer );
}
</syntaxhighlight>
 
==See also==
* {{Annotated link|Network socket}}
* {{Annotated link|Berkeley sockets}}
* {{Annotated link|Pipeline (Unix)}}
* {{Annotated link|Netlink}}
Line 471 ⟶ 29:
{{Reflist}}
 
==NotesExternal links==
* {{man|sh|socket|SUS||create a socket}}
{{Notelist}}
* {{man|sh|socketpair|SUS||create a pair of connected sockets}}
 
* {{man|sh|sendmsg|SUS||send a message on a socket}}
* {{man|sh|recvmsg|SUS||receive a message from a socket}}
* {{man|3|cmsg|Linux||socket ancillary data, including sending/receiving [[file descriptor]]s}}
* [https://untroubled.org/ucspi-unix/ ucspi-unix], UNIX-___domain socket client-server command-line tools
* [https://lists.freebsd.org/pipermail/freebsd-performance/2005-February/001143.html Unix sockets vs Internet sockets]
* [https://beej.us/guide/bgipc/html/multi/index.html Unix Sockets - Beej's Guide to Unix IPC]
 
{{Inter-process communication}}