UNIX Domain Properties
This section describe the properties of UNIX domain.
Item | Description |
---|---|
Types of sockets | In the UNIX domain, the SOCK_STREAM socket type provides pipe-like facilities, while the SOCK_DGRAM and SOCK_SEQPACKET socket types usually provide reliable message-style communications. |
Naming | Socket names are strings and appear in the file system name space through portals. |
Passing File Descriptors
- From a parent to a child by opening it in the parent and then either fork or exec another process. This has obvious shortcomings.
- Between any processes using a UNIX domain socket, as described below. This is a more general technique.
Passing a file descriptor from one process to another means taking an open file in the sending process and generating another pointer to the file table entry in the receiving process. To pass a file descriptor from any arbitrary process to another, it is necessary for the processes to be connected with a UNIX domain socket (a socket whose family type is AF_UNIX). Thereafter, one can pass a descriptor from the sending process by using the sendmsg() system call to the receiving process, which must perform the recvmsg() system call. These two system calls are the only ones supporting the concept of "access rights" which is how descriptors are passed.
Basically access rights
imply that the owning process has
acquired the rights to the corresponding system resource by opening
it. This right is then passed by this process (the sending process)
to a receiving process using the aforesaid system calls. Typically,
file descriptors are passed through the access rights mechanism.
Item | Description |
---|---|
caddr_t msg_accrights | access rights sent/received |
The file descriptor is passed through this field of the message header, which is used as a parameter in the corresponding sendmsg() system call.