AF_UNIX 域 - 为什么只使用本地文件名? [英] AF_UNIX domain - why use local file names only?

查看:35
本文介绍了AF_UNIX 域 - 为什么只使用本地文件名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 UNIX 域中使用 socket 时,建议使用路径名作为挂载在本地磁盘上的目录目录.UNIX 域只允许在同一台机器上工作的进程之间进行进程间通信.

When using socket in the UNIX domain, it is advisable to use path name for the directory directory mounted on the local disk. The UNIX domain only allows interprocess communication for process working on same machine.

你能解释一下上面的行吗?它是关于 UNIX 域中的一个套接字.

Can you please explain the above line? It is about a socket in the UNIX DOMAIN.

谢谢!

推荐答案

Unix 域套接字或 IPC 套接字(进程间通信套接字)是类似于 Internet 套接字的数据通信端点,但不使用网络通信协议.它在 POSIX 操作系统中用于进程间通信.正确的标准 POSIX 术语是 POSIX Local IPC Sockets.

A Unix domain socket or IPC socket (inter-process communication socket) is a data communications endpoint that is similar to an Internet socket, but does not use a network protocol for communication. It is used in POSIX operating systems for inter-process communication. The correct standard POSIX term is POSIX Local IPC Sockets.

Unix 域连接以字节流的形式出现,很像网络连接,但所有数据都保留在本地计算机中.UNIX 域套接字使用文件系统作为地址命名空间,即它们被进程引用为文件系统中的 inode.这允许两个不同的进程打开同一个套接字以进行通信.然而,实际的通信(数据交换)并不使用文件系统,而是缓存在内核内存中.

Unix domain connections appear as byte streams, much like network connections, but all data remains within the local computer. UNIX domain sockets use the file system as address name space, i.e. they are referenced by processes as inodes in the file system. This allows two distinct processes to open the same socket in order to communicate. However, the actual communication (the data exchange) does not use the file system, but buffers in kernel memory.

除了发送数据之外,进程还可以使用 sendmsg() 和 recvmsg() 系统调用通过 Unix 域套接字连接发送文件描述符.

In addition to sending data, processes can send file descriptors across a Unix domain socket connection using the sendmsg() and recvmsg() system calls.

这篇关于AF_UNIX 域 - 为什么只使用本地文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆