佛曰: 并非所有的socket都用于网络通信。
我说过,英语描述东西就是准确, 所以,还是看看维基百科怎么说吧:
A Unix domain socket or IPC socket (inter-process communication socket) is a data communications endpoint for exchanging data between processes executing within the same host operating system. While similar in functionality tonamed pipes, Unix domain sockets may be created as connection‑mode (SOCK_STREAM or SOCK_SEQPACKET) or as connectionless (SOCK_DGRAM), while pipes are streams only. Processes using Unix domain sockets do not need to share a common ancestry. The API for Unix domain sockets is similar to that of an Internet socket, but it does not use an underlying network protocol for communication. The Unix domain socket facility is a standard component ofPOSIX operating systems.
Unix domain sockets use the file system as their address name space. They are referenced by processes as inodes in the file system. This allows two processes to open the same socket in order to communicate. However, communication occurs entirely within the operating system kernel.
In addition to sending data, processes may send file descriptors across a Unix domain socket connection using thesendmsg()
and recvmsg()
system calls.
我喜欢代码,很多时候, 有这么一种感觉, 没有代码就没有真相。 一段可运行的代码例子,胜过很多无聊的讲解。我家里暂时没有unix/linux环境, 所以就没有代码分享, 在后续博文中,我会转载一些相关的文章,一起学习。