管道和承插口有什么区别? [英] What's the difference between pipe and socket?

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

问题描述

两者都可以用于不同进程之间的通信,

Both can be used for communicating between different processes,

有什么区别?

推荐答案

Windows有两种管道:匿名管道和命名管道.匿名管道(相当)与Unix管道非常相似-父进程的典型用法是将其设置为由子进程继承,并通常与子进程的标准输入,输出和/或错误流连接.一次,匿名管道的实现与命名管道完全不同,因此它们(例如)不支持重叠的I/O.从那时起,这种情况发生了变化,因此匿名管道基本上只是一个名称不明的命名管道,因此无法按名称打开它,但它仍然具有命名管道的所有其他功能(例如上面提到的重叠I/O功能).

Windows has two kinds of pipes: anonymous pipes and named pipes. Anonymous pipes correspond (fairly) closely to Unix pipes -- typical usage is for a parent process to set them up to be inherited by a child process, often connected to the standard input, output and/or error streams of the child. At one time, anonymous pipes were implemented completely differently from named pipes so they didn't (for one example) support overlapped I/O. Since then, that's changed so an anonymous pipe is basically just a named pipe with a name you don't know, so you can't open it by name, but it still has all the other features of a named pipe (such as the aforementioned overlapped I/O capability).

Windows命名管道更像是套接字.它们起源于OS/2,最初是创建客户端/服务器应用程序的主要机制.它们最初是围绕NetBIOS构建的(即使用NetBIOS进行寻址和传输).它们与Windows身份验证紧密集成,因此(例如)您可以让命名管道服务器模拟客户端,以限制服务器执行直接登录时客户端可以执行的操作.最近,MS摆脱了对NetBIOS的依赖,陷入了某种麻烦,但是,尽管它们现在可以使用IP作为其传输(以及用于寻址的DNS,即IIRC),但它们仍主要用于Windows计算机.在其他计算机上的主要用途是模仿Windows,例如通过运行Samba.

Windows named pipes are much more like sockets. They originated with OS/2, where they were originally the primary mechanism for creating client/server applications. They were originally built around NetBIOS (i.e., used NetBIOS both for addressing and transport). They're tightly integrated with things like Windows authentication, so you can (for example) have a named pipe server impersonate the client to restrict the server to doing things the client would be able to do if logged in directly. More recently, MS has gone to some trouble to get rid of the dependence on NetBIOS, but even though they can now use IP as their transport (and DNS for addressing, IIRC) they're still used primarily for Windows machines. The primary use on other machines is to imitate Windows, such as by running Samba.

这篇关于管道和承插口有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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