Is there any difference between socketpair and pair of unnamed pipes?

前端 未结 2 974

I would like to know not only user-side differences, but differences / common parts in Linux kernel implementation as well.

2条回答
  •  温柔的废话
    2021-01-30 19:04

    • 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.

    • socketpairs are normal AF_UNIX sockets, which means that ancillary messages like SCM_RIGHTS and SCM_CREDENTIALS can be passed over them.

    In the kernel, pipes are implemented in the filesystem code and socketpairs in the networking code.

提交回复
热议问题