本文介绍了管道和套接字有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了几个答案,但它们似乎与 Windows 机器特别相关.所以我的问题是管道和套接字之间有什么区别,你应该什么时候/如何选择一个?

I found a couple of answers, but they seem to be specifically relating to Windows machines.So my question is what are the differences between pipes and sockets, and when/how should you choose one over the other?

推荐答案

管道和套接字都处理字节流,但它们的处理方式不同......

Both pipes and sockets handle byte streams, but they do it in different ways...

  • 管道仅存在于特定主机中,它们指的是虚拟文件之间的缓冲,或连接该主机内进程的输出/输入.管道内没有数据包的概念.
  • 套接字使用 IPv4 或 IPv6 将通信打包;该通信可以扩展到本地主机之外.注意一个socket的不同端点可以共享同一个IP地址;但是,它们必须侦听不同的 TCP/UDP 端口才能这样做.

用法:

05-28 14:08
查看更多