问题描述
我不仅想了解用户方面的差异,还想知道Linux内核实现中的差异/常见部分.
I would like to know not only user-side differences, but differences / common parts in Linux kernel implementation as well.
推荐答案
-
管道是单向的,因此需要两个管道进行双向通信,而套接字对是双向的.
pipes are unidirectional, so you need two pipes to have bidirectional communication, whereas a socketpair is bidirectional.
管道始终面向流,而套接字对则面向数据报.
pipes are always stream-oriented, whereas socketpairs can be datagram-oriented.
套接字对是普通的
AF_UNIX
套接字,这意味着可以通过它们传递辅助消息,例如SCM_RIGHTS
和SCM_CREDENTIALS
.p>
socketpairs are normal
AF_UNIX
sockets, which means that ancillary messages likeSCM_RIGHTS
andSCM_CREDENTIALS
can be passed over them.在内核中,管道在文件系统代码中实现,套接字对在网络代码中实现.
In the kernel, pipes are implemented in the filesystem code and socketpairs in the networking code.
这篇关于套接字对和成对的未命名管道之间有什么区别吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!