Unix域套接字VS命名管道? [英] unix domain socket VS named pipes?
问题描述
在寻找一个UNIX名为socket,我认为他们被命名管道。我看着名字管道和没有看到多大的差别。我看见他们都不同初始化但多数民众赞成我发现的唯一的事情。无论使用C读/写功能和工作都AFAIK。
After looking at a unix named socket and i thought they were named pipes. I looked at name pipes and didnt see much of a difference. I saw they were initialized differently but thats the only thing i notice. Both use the C write/read function and work alike AFAIK.
请告诉我UNIX域套接字和命名管道之间的区别?当我挑一个比其他?我应该使用的默认情况下(如我如何在C ++中使用采用矢量默认不是使用双端队列,列表或者其他,如果我有需要)?
Whats the difference between unix domain sockets and named pipes? When would i pick one over the other? Which should i use by default (like how i use use vector by default in C++ than use deque, list or whatever else if i have needs)?
推荐答案
Unix域套接字通常比命名管道更灵活。他们的一些优点是:
UNIX-domain sockets are generally more flexible than named pipes. Some of their advantages are:
- 您可以(有可能连接多个客户端进程例如,一个服务器进程)。它们用于两个以上的进程通信
- 他们是双向的;
- 他们支持传递内核验证的UID / GID凭证进程之间;
- 他们支持传递进程间的文件描述符;
- 他们支持分组和顺序分组模式。
;
要使用很多的这些功能,你需要使用发送()
/ 的recv()
家庭系统调用,而不是的write()
/ 阅读()
。
To use many of these features, you need to use the send()
/ recv()
family of system calls rather than write()
/ read()
.
这篇关于Unix域套接字VS命名管道?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!